NS2 for Eclipse

NS2 for Eclipse

Eclipse is an open source development platform comprised of extensible frameworks, tools and runtimes for building, deploying and managing software across the lifecycle. A large and vibrant ecosystem of major technology vendors, innovative start-ups, universities, research institutions and individuals extend, complement and support the Eclipse platform.



Set up NS2 for Eclipse under Linux:

 

  • Download Eclipse SDK
  • Download Eclipse C++ Development Tooling
  • Extract Eclipse SDK to a folder, i.e. /home/username/eclipse
  • Extract Eclipse CDT to the same folder
  • Download NS2
  • Extract NS2 to a folder, i.e. /home/username/ns-allinone-2.29
  • Edit Makefile if necessary (see note below for details)
  • Build NS2
  • Start Eclipse
  • Choose your ns2 folder as your workspace folder, default:/home/username/ns-allinone-2.29
  • Create new C++ Project
    • Select File->New->Project...
    • Select C++->Standard C++ Make Project
    • Click Next
    • Enter ns-2.29 as your project name
    • Click Finish
  • Create a Launch Configuration
    • Select Run->Debug...
    • Select C/C++ Local Application
    • Click "New Launch Configuration"
    • Under Project, click Browse and select "ns-2.29"
    • Under C/C++ Application, click Search Project and select "ns"
    • Click Apply
    • Click Close

 

Note: The debugger needs debug information to be generated by the compiler. To make the compiler generate these informations, you have to edit the NS2 makefile. Edit ".../ns-allinone-2.29/ns-2.29/Makefile" or edit ".../ns-allinone-2.29/ns-2.29/Makefile.in" and run "./configure" after that. Add those lines anywhere:CCOPT = -g # Hinzufügen der "-g"-Option
DEFINE = -DNDEBUG # Löschen des NoDebug-Flags
DEFINE = -DDEBUG # Hinzufügen des Debug-Flags

Additional Note: Eclipse creates project and workspace files in the NS2 folder.These should be excluded from CVS checkins and patch creations. Add those files to your cvsignore, respectively delete them from your patchfile after creating it.


Set up NS2 for Eclipse under Windows

You need cygwin to run NS2 under Windows.

 

  • Download Cygwin
  • Install Cygwin
    • Run setup.exe
    • Choose a root directory, i.e. c:/cygwin
    • Make sure, unix/binary text file type is selected
    • Click Next
    • Choose a package directory, this is where your downloaded files will be put in
    • Select an internet connection and a download mirror
    • Make sure you install the following packages:

      xorg-x11-bin, xorg-x11-bin-dlls, xorg-x11-devel, xorg-x11-libs-data, xorg-x11-etc, gcc, gcc-g++, gawk, tar, gzip, make, patch, perl, w32api

       

    • Start cygwin.bat to create a user

 

 

  • Download Eclipse SDK
  • Download Eclipse C++ Development Tooling
  • Extract Eclipse SDK to a folder, i.e. c:/eclipse
  • Extract Eclipse CDT to the same folder
  • Download NS2
  • Extract NS2 to a cygwin folder, i.e. c:/cygwin/home/username/ns-allinone-2.29
  • Edit Makefile if necessary (see note below for details)
  • Build NS2
    • Start Cygwin.bat to get into cygwin shell
    • cd to your NS2-directory, default: /home/username/ns-allinone-2.29
    • Type "./install"
    • Type "./validate" if you want to validate your build
    • These steps may take a while

 

 

  • Start Eclipse
  • Choose your ns2 folder as your workspace folder, default:c:/cygwin/home/username/ns-allinone-2.29
  • Create new C++ Project
    • Select File->New->Project...
    • Select C++->Standard C++ Make Project
    • Click Next
    • Enter ns-2.29 as your project name
    • Click Finish
  • Change the Binary Parser
    • Select Project->Properties
    • Select C/C++ Make Project
    • In the Binary Parser Tab, select Cygwin PE Parser and PE Windows Parser
    • Click OK
  • Create a Launch Configuration
    • Select Run->Debug...
    • Select C/C++ Local Application
    • Click "New Launch Configuration"
    • Under Project, click Browse and select "ns-2.29"
    • Under C/C++ Application, click Search Project and select "ns.exe"
    • Click Apply
    • Click Close

 

Note: The debugger needs debug information to be generated by the compiler. To make the compiler generate these informations, you have to edit the NS2 makefile. Edit ".../ns-allinone-2.29/ns-2.29/Makefile" or edit ".../ns-allinone-2.29/ns-2.29/Makefile.in" and run "./configure" after that. Add those lines anywhere:CCOPT = -g # Hinzufügen der "-g"-Option
DEFINE = -DNDEBUG # Löschen des NoDebug-Flags
DEFINE = -DDEBUG # Hinzufügen des Debug-Flags

Additional Note: Eclipse creates project and workspace files in the NS2 folder.These should be excluded from CVS checkins and patch creations. Add those files to your cvsignore, respectively delete them from your patchfile after creating it.

From: http://wcms1.rz.tu-ilmenau.de/fakia/NS2-for-Eclipse.6025.0.html

有些朋友好像對Eclipse CDT開發很感興趣,我就把我用Eclipse搭建NS2開發平臺的過程說一下吧,經驗和大家共享。
一、我的開發環境:Mware 6.5 + Fedora Core 8 + NS 2.31+Eclipse CDT+DLTK
    Eclipse CDT用的是 Europa 版本的。這個版本直接裝好了Eclipse 的CDT插件。也可以用Fedora內自帶的Eclipse在單獨裝上CDT插件就行了,DLTK是一個TCL和Ruby的插件,實際上我只用它的高亮顯示Tcl關鍵字的功能,不裝也可以。我的NS安裝路徑爲~/ns-allinone-2.31/ns-2.31/
二、過程摘要:
1.裝好VMware和linux
2.裝好NS2。配置好環境變量。
a) 運行在ns2目錄下運行 ./configure –enable-debug
3.安裝好Eclipse CDT
4.安裝DLTK插件(可選)
5.新建C++ makefile工程 workspace指定到 ~/ns-allinone-2.31/ns-2.31
6.設置
a) 把ns目錄下所有文件夾添加爲source文件夾
b) 設定Run配置:添加ns可執行文件和變量(tcl腳本的位置)
7.運行 在console中可以看到結果
如果你已經知道怎麼做了,那就開始吧。如果不清楚那就接着看下面的詳細步驟
三、詳細步驟:
    1-4 網上有大量資料可以參考,我簡單的說幾點:
        a) VMware 6.5不要裝FC7。因爲vmware-tools和FC7的內核似乎不兼容,需要將FC7內核升級到2.6.23以上。所以還是裝FC8。或者用VMware5.5也行。
        b) ./configure –enable-debug在make文件中加入-g屬性 然後重新編譯一下ns
        c) Eclipse需要安裝JAVA虛擬機。簡單的方式是安裝linux時完全安裝一下,FC8中已經把開發環境都配置好了
現在假設你已經安裝好了所有需要的軟件,NS可以正常運行,那麼把NS導入到Eclipse中就可以了。具體步驟如下:
        a) 新建C++ makefile工程:在Project Explorer中右鍵,新建C++工程;
        b) 設置工程屬性:注意位置是ns的安裝目錄,類型是makefile project,tool chain選linux GCC;
        c) 完成
        d) 在工程名上右鍵,選properties;
        e) 在C/C++ General -> paths and symbols中選則source location;添加NS目錄下所有文件夾爲source;這是爲了可以從大綱視圖看代碼;
        f) 設置Run:雙擊C/C++ Local Application, 新建一個Run配置;C/C++ Application中選擇目錄下的ns可執行文件。enable-debug後這個文件變大爲10幾M了。
        g) 設置Arguments;把你所要仿真的tcl腳本添加進去。相當於在終端中輸入ns yourTcl.tcl
        h) 運行。如果沒有設定變量,相當於直接運行ns。Console中提示符變爲%; 我們可以測試一下輸入
puts “Hello NS2”
輸出Hello NS2
安裝結束。Enjoy it!
四、Eclipse的作用(歡迎大家討論)
1.Debug
    Eclipse調試C++也是調用GDB,相當於一個可視化的GDB調試環境;使用時設定斷點,點debug按鈕即可。
2.查找代碼
    Eclipse在項目中查找代碼的作用我認爲非常管用,你可以查一個關鍵字或者類名,看它在那定義的。只需要在變量名上ctrl+左鍵單擊,就自動打開定義文件。感覺很爽 ^_^ 看代碼會省很多事。
3.CVS
    寫代碼的時候還是用用這些代碼管理軟件比較好。省得改錯了代碼時想回都回不去,欲哭無淚啊。
4 ……希望大家在使用中自己多多發現
    我也是一個NS2和Eclipse的新手,希望大家多多發現Eclipse在NS2編程上的技巧,相互交流,有了發現也告訴我一聲啊。^_^

 

From: http://jimey.com/2009/03/06/%E4%BD%BF%E7%94%A8eclipse-cdt-%E5%BC%80%E5%8F%91ns2.html

 

NS2在Win系統中三種調試方法
NS2是開源的,因此其基本的編譯和調試工具爲GCC和GDB,不管你是將它安裝在window、linux 中。在window系統中,GCC和GDB比較的承載平臺爲Cygwin。因此在window中使用NS2一般建議大家先安裝Cygwin,注意你必須安裝GCC和GDB。在此前提下,你可以選擇的調試方式有三種。
1、直接使用GDB,在Cygwin現在版本中,它包含的GDB包有兩種分別是 2006XXX和2004XXX,它們都是基於命令行的方式。據說早期的GDB中有圖形調試方式,它們是2001XXX或2002XXX,大家如果有興趣可以在網絡上找找。對現在已經熟悉了window操作方式的人來講,命令行的方式的確有些不方便。見GDB圖片
2、DDD,它是可以圖形操作方式,底層是GDB。它提供了一個GDB的命令窗口,和源碼查看窗口。另外你可以直接在源碼中設置斷點,調試跟蹤時,可以直觀的查看變量、參數等。比起命令行的操作方式方面多了,但調試時,響應速度比較慢。還有源碼查看窗口代碼沒有着色,沒有層次感。見DDD圖片
3、Eclipse+CDT,它構建了一個比較好的IDE平臺,明顯優於前面的兩種方法。反應速度快,查看代碼方便,類的結構清晰。這種方法應該是目前比較好的NS2編譯與調試方案。在搭建Eclipse+CDT平臺時應該注意幾點:
消去部分編譯影響速度的選項,如:code assisant, code indexer一般不需要,binary parser設置爲PE Windows Parser。
建立NS2項目時,選擇stand make C++ project, 不要勾選use default location而是選擇NS2的安裝路徑。
如果需要調試,你必須在GCC的選項中添加-g。你可以通過修改Makefile完成,也可以通過在cygwin命令行中運行configure with-enable-debug完成。
調試時,你可能遇到無法找到源文件的情況,這是由於cygwin在作怪。cygwin中的路徑標識與windows存在一定的差異,因此你必須做一定的映像,例如/cygdrive/c <----> C:/; /cygdrive/d <----> D:/等等。映射的設置方法爲perferences -> C/C++ -> Debug -> command Source LookUP Path,添加Path Mapping。注意cygwin的安裝路徑也是很重要的,一般也必須添加到映射中,例如cygwin的根目錄 “/<-->C:/cygwin”。

From: http://blog.chinaunix.net/u2/82448/showart.php?id=1888082

發佈了29 篇原創文章 · 獲贊 1 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章