2010年9月9日 星期四

在linux fc5下裝ns 2.29

.

Efficient Simulation of Large-Scale P2P Networks Packet-level vs. Flow-level Simulations
這篇paper的作者Kolja Eger用ns2寫了bittorrent的simulation,並open source

所以想要用ns2寫p2p simulation的人,這個東西會是個不錯的參考

原本bittorrentsim是放在作者學校的網站上:
http://www.tuhh.de/et6/research/bittorrentsim/

然而,Kolja Eger畢業了,網站被移除了
經詢問,Eger把code改放到他的google site
https://sites.google.com/site/koljaeger/bittorrent-simulation-in-ns-2

然而,他的bittorent code是以patch file release的,並且是給ns-2.29用的

為此,我必需裝一個ns-2.29來安裝他的bittorrentsim

然而,安裝ns-2.29的過程不那麼順利
make時會有一堆error,據悉是gcc改版,規則變嚴格的原因
(這個我有印象,有次gcc更新後,本來可以make的code會make過不了)

我特地找個比較久的linux virtualbox image:Fedora Core 5
沒想這個distribution的gcc還蠻新的:gcc version 4.1.0 20060304 (Red Hat 4.1.0-3)
(其實我不確定是distribution本來的版本就這麼新,還是我以前有做過更新……)
所以make ns-2.29還是會有一堆error

要安裝ns-2.29時會出現一堆error,按照下列這個連結的方法就可以裝起ns-2.29
ns-2.29在Ubuntu8.04中的安装
基本上面文章的解法可行,按照他的方法,我把ns-2.29裝起來了

但是過程中會遇到另一個問題是文章中沒提到的,據說是bash 3.1.I的關係
error code如下:

checking system version (for dynamic loading)... ./configure: line 6017: syntax error near unexpected token `('


在ns-allinone-2.29的目錄下,複製下面這行:
for f in $(find -name configure); do sed "s/relid'/relid/" -i $f; done
貼上,執行,問題就解了
這個解法的原文出處:Compiling Network Simulator 2.29

到這裡,就裝好ns-2.29了
可以開始動手安裝bittorrentsim了


.

在linux fc5下裝VirtualBox guest addition

.

為什麼現在還要回頭使用linux fedora core 5呢?
……

因為,我要裝ns2 2.29
因為,BittorentSim的patch file是for ns2 2.29
而ns2 2.29在太新的gcc下……會裝不起來……

我有兩個選擇:
1.要嘛在新的gcc裝起ns2 2.29
2.要嘛就是在較舊的linux下裝ns2 2.29

solution 1我試過,但失敗了

所以我現在要試solution 2

但solution 2面臨到的第一個難題是:我要裝guest addtion
但fedora core系列都沒有linux kernal src header
而要安裝guest addition,就需要有linux kernal src header
否則就會遇到如下的錯誤:

Building the VirtualBox Guest Additions kernel modules [FAILED]
Your system does not seem to be set up to build kernel modules.


這個難題我很久以前就遇過了,因為即使是vmware的guest os,也是要裝vmware guest tool
不是只有vitualbox才有這問題


為什麼要裝guest addtion這個原因我就不解釋了,簡單的說,不裝guest addtion我用不下去

好,我們現在就來解問題:
怎裝linux kernal src header?

有人說:

yum install kernel-devel-$(uname -r)


以前這個指令是對的,但現在不work,因為fc5太舊了,官方不maintain了


好,那找其他的repository如何?
如新竹縣網的

http://apt.nc.hcc.edu.tw/web/yum_setup.htm


裝好了之後,yum update可以使用
但還是找不到linux kernal source hdr
錯誤如下:

Error: failure: Fedora/RPMS/kernel-devel-2.6.15-1.2054_FC5.i686.rpm from core: [Errno 256] No more mirrors to try.



好,到這裡線索已經出來了,我們至少知道fc5的kernel src hdr的rpm name為:kernel-devel-2.6.15-1.2054_FC5.i686.rpm

上網google一下kernel-devel-2.6.15-1.2054_FC5.i686.rpm,隨便捉一個下來
安裝:

rpm -ivh kernel-devel-2.6.15-1.2054_FC5.i686.rpm


然後再裝一次guest addition

./VBoxLinuxAdditionals-x86.run --target ~/vbox


恭喜,終於裝成功了,我有guest addtion 可以用了
有圖有真相



.

2010年8月3日 星期二

ubuntu 9.10下安裝oversim

.

首先要安裝oversim
在./configure時,會出現下列error
configure: error: zlib or zlib header file not found, please install it

此時要安裝zlib
我是裝zlib1g-dev
sudo apt-get install zlib1g-dev

裝完後,就可以bypass該error

但還是會出現新的error:
configure: error: Cannot run wish (wish command "puts OK; exit" failed): maybe you are not running X or DISPLAY environment variable not set?

原來要在xwin下的console去執行./configure(我習慣用遠端)
在xwin下再執行一次./configure,就過了,只是會出現一些warning

configure: error: Cannot run wish (wish command "puts OK; exit" failed): maybe you are not running X or DISPLAY environment variable not set?

WARNING: The configuration script could not detect the following packages:

MPI (optional) LibXML/Expat Akaroa (optional)

Scroll up to see the warning messages (use shift+PgUp), and search config.log
for more details. While you can use OMNeT++ in the current configuration,
be aware that some functionality may be unavailable or incomplete.


WARNING: your PATH doesn't contain /home/gdemon/oversim/omnetpp-4.1/bin!
Add the following line to your .profile or .bash_profile (provided you use bash):
export PATH=$PATH:/home/gdemon/oversim/omnetpp-4.1/bin


WARNING: The TCL_LIBRARY environment variable is not set, and without it
Tkenv (the GUI runtime environment) may be unable to find the BLT library.

Add the following line to your .profile or .bash_profile (provided you use bash):
export TCL_LIBRARY=/usr/share/tcltk/tcl8.4

For additional information, please visit the "Common installation problems"
page on www.omnetpp.org.

.

2010年7月8日 星期四

ubuntu下找不到pthread_create的man page

.

最近linux都改用ubuntu了
在ubuntu下預設是沒有pthread_create的man page,要再自己加裝才行

sudo apt-get install manpages-posix-dev

裝完就man得到了

.

2010年7月6日 星期二

在notepad++下新增awk language的highlight

.

Notepad ++沒有內建awk語言的highligh,因此我們要自己利用user define新增

在網路上找了一下,有人自訂出awk language highlight (文章原始出處)

做法如下:
在 "%APPDATA%\Notepad++"下找到'userDefineLang.xml",開啟它,貼上原始文章中自訂的文字
若 "%APPDATA%\Notepad++"下沒有'userDefineLang.xml"這個檔案,則自行新增一個同名的檔案,再貼上
在這我提到改好的userDefineLang.xml,請按下面的連結,下載後,移過去即可
按此下載awk language highlight
然後重開NotePad++即可在工具列->程式語言(language)下找到awk的選項了



%APPDATA%的位置在每個人的電腦上不一定
在windows 7上,是在使用者的家目錄下的"AppData\Roaming"
若不知道,則進入cmd line(開始->執行->cmd),然後打"echo %AppData%,下面秀出來的位置就是你電腦上的%AppData%所在位置,如下圖



.

改變notepad ++的佈景顏色

.

我個人習慣使用黑底白字的編輯器
而現在大部份的編輯器都有主題的設計,可以讓你從default的白底黑字去選擇其他主題,如黑底白字,或黑底黃字等

使用主題換顏色的好處是,在編輯器會針對不同語言的關鍵字highlight的情況下,換主題通常不會影嚮highlight的效果

而notepad ++如何切換主題?
在找了許久終於被我找到了

工具列->自訂->設定程式語言格式
然後再從"主題選取"選擇你想要的主題即可
我現在是使用blackboard style

.

2010年4月29日 星期四

如果sementation fault發生在STL的map中?

.

如果sementation fault發生在STL的map中,而非你寫的程式,該怎麼辦?
google了一下,大家都說是memory access跨boundary,這其實是廢話,因為sementation fault本身就imply這個事實

個人有發生過一個case,提出來供大家參考
當我在struct中宣告一個map時,這個struct能否動態被配置記憶體並使用?
答案是可以,但是在該struct被new出來後,不可以用memset去清空

如下的struct,在new出來後,若用memset去清空該struct,再去使用該struct中的map,就會出現
"程式記憶體區段錯誤"
若不清空,則就可以正常使用

struct peer_ent {
unsigned long IP; // the IP of the remote peer.
map tcp_conn_tbl; // key == lport + wport (4B)
map udp_conn_tbl; // key == lport + wport (4B)
unsigned long time; // 20100320: ????
unsigned char is_1st_pkt;
unsigned char dir; // when the peer's dir == the dir of 1st conn between the host and peer
unsigned char rsvr[2]; // reserved
};

.