转:Ubuntu6.10 + ns2.1b9a安装过程详解

转载自:http://sunreset.blogbus.com/logs/7633086.html

ns2的安装过程非常简单,只用下载相应的allinone压缩包,然后直接解压再./install就可以了。但由于gcc编译器版本的问题,在 目前通用的linux上安装低版本的ns2也成了一种麻烦。由于工作的需要,我要搭建一个ns2.1b9a的环境。最开始我以为只要半天功夫就能搞定,却 没料到花了我三天的时间。。。
问题最终是解决了,现在才发现google的搜索引擎是如此强大,也要感谢网上很多人默默的将自己的经验奉献出来。我在这里也将我的解决方案拿出来和大家共享。

环境:ubuntu6.10
目标:安装ns2.1b9a
步骤:
1.安装build-essential
sudo apt-get install build-essential
2.安装libxmu-dev
sudo apt-get install libxmu-dev
3.安装gcc-3.3,g++-3.3;直接使用ubuntu自带的新立得就可以
4.设置环境变量
export CC=/usr/bin/gcc-3.3
export CCC=g++-3.3
export CXX=/usr/bin/g++-3.3
5.下载ns2.1b9a并解压
ns2.1b9a下载地址:http://www.isi.edu/nsnam/dist/ns-allinone-2.1b9a-gcc32.tar.gz
tar xzvf ns-allinone-2.1b9a-gcc32.tar.gz
6.touch ns-allinone-2.1b9a/tcl8.3.2/generic/tclStubInit.c
7.安装补丁ns21b9a-gcc33.patch(download)
cd ns-allinone-2.1b9a;patch -p0 < ../ns21b9a-gcc33.patch
8.开始安装ns2
./install
9.配置ns2环境变量
vi /home/wl/.bash_profile
add following lines to the end
-------->
export NS_HOME=/home/wl/ns-allinone-2.1b9a
export PATH=$PATH:$NS_HOME/bin:$NS_HOME/tcl8.3.2/unix:$NS_HOME/tk8.3.2/unix
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NS_HOME/otcl-1.0a8:$NS_HOME/lib:$NS_HOME/tcl8.3.2/unix:$NS_HOME/tk8.3.2/unix
export TCL_LIBRARY=$NS_HOME/tcl8.3.2/library/
--------<
source .bash_profile 使刚才添加的环境变量生效
10.校验
cd ns-2.1b9a; ./validate

至此ns2.1b9a安装成功,但校验没有全部通过(test-all-red failed)
      在解决问题的过程中也学到了一些东西,如patch文件的结构。Patch 文件中常见的@@ -45,7 +45,7 @@表示为一个块HUNK的开始,其中-45,7表示原来该块从第45开始共7行,+45,7表示打过补丁之后从45行开始共7行。具体的可以参考:How to create and use a patch in Linux
-----------------------------------------------------------------------------
下面给出安装过程中出现的错误,希望对于也正在为安装而烦恼的同胞有些帮助:)

Description-------->
./tclsh ./../tools/genStubs.tcl ./../generic /
./../generic/tcl.decls ./../generic/tclInt.decls
make: ./tclsh: Command not found
Solution-----------<
touch ../tcl8.3.2/generic/tclStubInit.c
reference<-------->
http://www.isi.edu/nsnam/ns/ns-problems.html

Description-------->
  tclcl-mappings.h: In static member function `static int TclObjectHelper::dispatch_(void*, Tcl_Interp*, int, char**)':
  tclcl-mappings.h:51: error: incomplete type `Tcl' used in nested name specifier
  tclcl-mappings.h:52: error: invalid use of undefined type `struct Tcl'
  tclcl-mappings.h:41: error: forward declaration of `struct Tcl'
  tclcl-mappings.h:57: error: invalid use of undefined type `struct Tcl'
  tclcl-mappings.h:41: error: forward declaration of `struct Tcl'
  make: *** [Tcl.o] Error 1
  tclcl-1.15 make failed! Exiting ...
Solution-----------<
--- tclcl-1.0b12/tclcl.h 2004-01-12 19:52:09.000000000 -0500
+++ tclcl-1.0b12/tclcl.h 2004-12-16 08:43:45.838930336 -0500
@@ -45,7 +45,7 @@
 }
 
 #include "tclcl-config.h"
-#include "tclcl-mappings.h"
+// #include "tclcl-mappings.h"
 #include "tracedvar.h"
 
 struct Tk_Window_;
@@ -157,6 +157,8 @@
  Tcl_HashTable objs_;
 };
 
+#include "tclcl-mappings.h"
+
 class InstVar;
 
 class TclObject {
reference<-------->
http://www.ececs.uc.edu/~cdmc/ucbt/src/ns227-gcc34.patch
http://blog.tianya.cn/blogger/post_show.asp?idWriter=0&Key=0&BlogID=78856&PostID=9333930

Description-------->
./mobile/god.h:88: error: extra qualification 'vector::' on member
'operator='
./mobile/god.h:93: error: extra qualification 'vector::' on member
'operator+='
./mobile/god.h:98: error: extra qualification 'vector::' on member
'operator=='
./mobile/god.h:101: error: extra qualification 'vector::' on member
'operator!='make: *** [src_rtg/sragent.o] Error 1
Solution-----------<
--- ns-2.1b9a/mobile/god.h 2005-10-19 21:45:22.000000000 -0700
+++ ns-2.1b9a/mobile/god.h 2006-05-02 19:33:57.000000000 -0700
@@ -85,20 +85,20 @@
   return sqrt(X*X + Y*Y + Z*Z);
  }
 
- inline void vector::operator=(const vector a) {
+ inline void operator=(const vector a) {
   X = a.X;
   Y = a.Y;
   Z = a.Z;
  }
- inline void vector::operator+=(const vector a) {
+ inline void operator+=(const vector a) {
   X += a.X;
   Y += a.Y;
   Z += a.Z;
  }
- inline int vector::operator==(const vector a) {
+ inline int operator==(const vector a) {
   return (X == a.X && Y == a.Y && Z == a.Z);
  }
- inline int vector::operator!=(const vector a) {
+ inline int operator!=(const vector a) {
   return (X != a.X || Y != a.Y || Z != a.Z);
  }
  inline vector operator-(const vector a) {
reference<-------->
https://www.ececs.uc.edu/~cdmc/ucbt/src/ns2292-gcc410.patch

Description-------->
 queue/cbq.cc:112: error: ISO C++ forbids declaration of ‘CBQueue’ with no type
 queue/cbq.cc:112: error: expected ‘;’ before ‘*’ token
 queue/cbq.cc: In member function ‘virtual int CBQueue::insert_class(CBQClass*)’:
 queue/cbq.cc:488: error: ‘class CBQClass’ has no member named ‘cbq_’
 queue/cbq.cc: In constructor ‘CBQClass::CBQClass()’:
 queue/cbq.cc:805: error: class ‘CBQClass’ does not have any field named ‘cbq_’
 queue/cbq.cc: In member function ‘virtual void CBQClass::recv(Packet*, Handler*)’:
 queue/cbq.cc:850: error: ‘cbq_’ was not declared in this scope
 queue/cbq.cc:856: error: ‘cbq_’ was not declared in this scope
 queue/cbq.cc: In member function ‘void CBQClass::update(Packet*, double)’:
 queue/cbq.cc:873: error: ‘cbq_’ was not declared in this scope
 queue/cbq.cc: In member function ‘int CBQClass::desc_with_demand()’:
 queue/cbq.cc:928: error: ‘cbq_’ was not declared in this scope
 queue/cbq.cc: In member function ‘void CBQClass::newallot(double)’:
 queue/cbq.cc:975: error: ‘cbq_’ was not declared in this scope
 queue/cbq.cc: In member function ‘virtual int CBQClass::command(int, const char* const*)’:
 queue/cbq.cc:1002: error: ‘cbq_’ was not declared in this scope
 make: *** [queue/cbq.o] Error 1
Solution-----------<
--- ns-2.1b9a/queue/cbq.cc 2006-08-31 11:42:09.000000000 -0300
+++ ns-2.1b9a/queue/cbq.cc 2006-08-31 11:43:31.000000000 -0300
@@ -87,6 +87,8 @@
 #define LEAF_LEVEL 1 /* level# for leaves */
 #define POWEROFTWO 16
 
+class CBQueue;
+
 class CBQClass : public Connector {
 public:
  friend class CBQueue;
reference<-------->
http://blog.tianya.cn/blogger/post_show.asp?idWriter=0&Key=0&BlogID=78856&PostID=9333930
http://larsis.inf.ufpr.br/maverson/

Description-------->
 webcache/webtraf.cc: In member function ‘virtual int WebTrafPool::command(int, const char* const*)’:
 webcache/webtraf.cc:415: error: ISO C++ forbids initialization in array new
 make: *** [webcache/webtraf.o] Error 1
Solution-----------<
--- ns-2.1b9a/webcache/webtraf.cc 2006-08-31 11:48:37.000000000 -0300
+++ ns-2.1b9a/webcache/webtraf.cc 2006-08-31 11:50:54.000000000 -0300
@@ -362,10 +362,12 @@
    return (TCL_OK);
   } else if (strcmp(argv[1], "set-num-server") == 0) {
    nServer_ = atoi(argv[2]);
-   if (server_ != NULL)
-    delete []server_;
-   server_ = new WebServer[nServer_](this);
-
+   if (server_ != NULL)
+    free(server_);
+   server_ = (WebServer*)malloc(nServer_ * sizeof(WebServer));
+   for (int i = 0; i < nServer_; i++) {
+    server_[i] = WebServer(this);
+   }
    return (TCL_OK);
   } else if (strcmp(argv[1], "set-num-client") == 0) {
reference<-------->
http://www.ececs.uc.edu/~cdmc/ucbt/src/ns227-gcc34.patch
http://larsis.inf.ufpr.br/maverson/

Description-------->
 ./tora/tora_neighbor.h:72: error: ISO C++ forbids declaration of ‘toraAgent’ with no type
 ./tora/tora_neighbor.h:72: error: expected ‘;’ before ‘*’ token
 make: *** [tora/tora.o] Error 1
Solution-----------<
--- ns-2.1b9a/tora/tora_neighbor.h 2006-08-31 11:42:09.000000000 -0300
+++ ns-2.1b9a/tora/tora_neighbor.h 2006-08-31 11:43:31.000000000 -0300
@@ -41,6 +41,8 @@
 #ifndef __tora_neighbor_h__
 #define __tora_neighbor_h__
 
+class toraAgent;
+
 enum LinkStatus {
  LINK_UP = 0x0001, // upstream
  LINK_DN = 0x0002, // downstream
reference<-------->
http://blog.tianya.cn/blogger/post_show.asp?idWriter=0&Key=0&BlogID=78856&PostID=9333930
http://larsis.inf.ufpr.br/maverson/

Description-------->
diffusion/omni_mcast.cc:388: error: ‘OmniMcastXmitFailedCallback’ was not declared in this scope 
make: *** [diffusion/omni_mcast.o] Error 1
Solution-----------<
--- ns-2.1b9a/diffusion/omni_mcast.cc 2005-10-19 21:45:22.000000000 -0700
+++ ns-2.1b9a/diffusion/omni_mcast.cc 2006-05-02 19:33:57.000000000 -0700
@@ -59,6 +59,8 @@
 #include "dsr/path.h"
 #include "god.h"
 
+void OmniMcastXmitFailedCallback(Packet *pkt, void *data);
+
 static class OmniMcastClass : public TclClass {
 public:
   OmniMcastClass() : TclClass("Agent/OmniMcast") {}
reference<-------->
https://www.ececs.uc.edu/~cdmc/ucbt/src/ns2292-gcc410.patch

Description-------->
dsr/dsragent.cc: In method `DSRAgent::DSRAgent()':
dsr/dsragent.cc:313: stray '/' in program
make: *** [dsr/dsragent.o] Error 1
Solution-----------<
--- ns-2.1b9a/dsr/dsragent.cc 2005-10-19 21:45:22.000000000 -0700
+++ ns-2.1b9a/dsr/dsragent.cc 2006-05-02 19:33:57.000000000 -0700
@@ -188,6 +188,9 @@
 
 */
 
+void XmitFlowFailureCallback(Packet *pkt, void *data);
+void XmitFailureCallback(Packet *pkt, void *data);
+
 /*===========================================================================
   SendBuf management and helpers
 ---------------------------------------------------------------------------*/
reference<-------->
https://www.ececs.uc.edu/~cdmc/ucbt/src/ns2292-gcc410.patch

Description-------->
diffusion/diffusion.h:152: error: type specifier
omitted for parameter
diffusion/diffusion.h:152: error: syntax error before
numeric constant
diffusion/diffusion.cc:406: error: type specifier
omitted for parameter
diffusion/diffusion.cc:406: error: syntax error before
numeric constant
diffusion/diffusion.cc: In member function `void
DiffusionAgent::MACsend(...)':
diffusion/diffusion.cc:408: error: `pkt' undeclared
(first use this function)
diffusion/diffusion.cc:408: error: (Each undeclared
identifier is reported only
   once for each function it appears in.)
diffusion/diffusion.cc:432: error: `delay' undeclared
(first use this function)
make: *** [diffusion/diffusion.o] Error 1
Solution-----------<
--- ns-2.1b9a/diffusion/diffusion.cc 2005-10-19 21:45:22.000000000 -0700
+++ ns-2.1b9a/diffusion/diffusion.cc 2006-05-02 19:33:57.000000000 -0700
@@ -58,6 +58,8 @@
 #include "god.h"
 #include "routing_table.h"
 
+void XmitFailedCallback(Packet *pkt, void *data);
+
 char *MsgStr[]= {"", "INTEREST", "DATA", "DATA_READY", "DATA_REQUEST",
   "POS_REINFORCE", "NEG_REINFORCE", "INHIBIT", "TX_FAILED",
   "DATA_STOP" };
reference<-------->
https://www.ececs.uc.edu/~cdmc/ucbt/src/ns2292-gcc410.patch

Description-------->
tcp/tcp-sack-rh.cc:68: error: extra qualification ‘SackRHTcpAgent::’ on member ‘newack’
make: *** [tcp/tcp-sack-rh.o] Error 1
Solution-----------<
--- ns-2.1b9a/tcp/tcp-sack-rh.cc 2005-10-19 21:45:25.000000000 -0700
+++ ns-2.1b9a/tcp/tcp-sack-rh.cc 2006-05-02 19:33:57.000000000 -0700
@@ -65,7 +65,7 @@
  virtual void estadjust();
  virtual void rhclear();
  virtual void computefack();
- virtual void SackRHTcpAgent::newack(Packet* pkt);
+ virtual void newack(Packet* pkt);
  protected:
  int fack_;           /* the FACK state variable  */
  int retran_data_;         /* the number of retransmitted packets in the pipe  */
reference<-------->
https://www.ececs.uc.edu/~cdmc/ucbt/src/ns2292-gcc410.patch

Description-------->
 linkstate/ls.h: In member function ‘void LsList<_Tp>::eraseAll()’:
 linkstate/ls.h:89: error: there are no arguments to ‘begin’ that depend on a template parameter, so a declaration of ‘begin’ must be available
 linkstate/ls.h:89: error: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
 linkstate/ls.h:89: error: there are no arguments to ‘end’ that depend on a template parameter, so a declaration of ‘end’ must be available
 linkstate/ls.h: In member function ‘void LsMap<Key, T>::eraseAll()’:
 linkstate/ls.h:112: error: there are no arguments to ‘begin’ that depend on a template parameter, so a declaration of ‘begin’ must be available
 linkstate/ls.h:112: error: there are no arguments to ‘end’ that depend on a template parameter, so a declaration of ‘end’ must be available
 make: *** [linkstate/ls.o] Error 1
Solution-----------<
--- ns-2.1b9a/linkstate/ls.h 2006-08-31 12:08:42.000000000 -0300
+++ ns-2.1b9a/linkstate/ls.h 2006-08-31 12:10:16.000000000 -0300
@@ -86,7 +86,7 @@
  LsList() : baseList() {}
  LsList(const _Tp& x) : baseList(1, x) {}
  void eraseAll() {
-  baseList::erase(begin(), end());
+  baseList::erase(baseList::begin(), baseList::end());
  }
 LsList<_Tp>& operator= (const LsList<_Tp> & x) {
  return (LsList<_Tp> &)baseList::operator= (x);
@@ -109,7 +109,7 @@
   return ib.second ? ib.first : baseMap::end();
  }
 
- void eraseAll() { erase(begin(), end()); }
+ void eraseAll() { baseMap::erase(baseMap::begin(), baseMap::end()); }
  T* findPtr(Key key) {
   iterator it = baseMap::find(key);
   return (it == baseMap::end()) ? (T *)NULL : &((*it).second);
reference<-------->
http://larsis.inf.ufpr.br/maverson/

Description-------->
pgm/pgm-agent.cc:275: error: extra qualification ‘PgmAgent::’ on member ‘trace_event’
make: *** [pgm/pgm-agent.o] Error 1
Solution-----------<
--- ns-2.1b9a/pgm/pgm-agent.cc 2005-10-19 21:45:23.000000000 -0700
+++ ns-2.1b9a/pgm/pgm-agent.cc 2006-05-02 19:33:57.000000000 -0700
@@ -275,7 +275,7 @@
 
   void print_stats();
 
-  void PgmAgent::trace_event(char *evType, double evTime);
+  void trace_event(char *evType, double evTime);
 
 #ifdef PGM_DEBUG
   void display_packet(Packet *pkt);
reference<-------->
https://www.ececs.uc.edu/~cdmc/ucbt/src/ns2292-gcc410.patch

Description-------->
pgm/pgm-receiver.cc:157: error: extra qualification ‘PgmAgent::’ on member ‘trace_event’
make: *** [pgm/pgm-receiver.o] Error 1
Solution-----------<
--- ns-2.1b9a/pgm/pgm-receiver.cc 2005-10-19 21:45:23.000000000 -0700
+++ ns-2.1b9a/pgm/pgm-receiver.cc 2006-05-02 19:33:57.000000000 -0700
@@ -154,7 +154,7 @@
   void print_stats();
   void display_packet(Packet *pkt); // For debugging.
 
-  void PgmReceiver::trace_event(char *evType, double evTime);
+  void trace_event(char *evType, double evTime);
 
   EventTrace * et_;  //Trace Object for Custom Event Trace
 
reference<-------->
https://www.ececs.uc.edu/~cdmc/ucbt/src/ns2292-gcc410.patch

Description-------->
pgm/pgm-sender.cc:161: error: extra qualification ‘PgmAgent::’ on member ‘trace_event’
make: *** [pgm/pgm-sender.o] Error 1
Solution-----------<
--- ns-2.1b9a/pgm/pgm-sender.cc 2005-10-19 21:45:23.000000000 -0700
+++ ns-2.1b9a/pgm/pgm-sender.cc 2006-05-02 19:33:57.000000000 -0700
@@ -157,7 +157,7 @@
 
   void display_packet(Packet *pkt); // For debugging.
 
-  void PgmSender::trace_event(char *evType, nsaddr_t daddr, double evTime);
+  void trace_event(char *evType, nsaddr_t daddr, double evTime);
 
   EventTrace * et_;  //Trace Object for custom Event Traces
 
reference<-------->
https://www.ececs.uc.edu/~cdmc/ucbt/src/ns2292-gcc410.patch

Description-------->
 diffusion3/lib/nr/nr.hh:224: error: an explicit specialization must be preceded by ‘template <>’
 diffusion3/lib/nr/nr.hh:239: error: an explicit specialization must be preceded by ‘template <>’
 make: *** [diffusion3/lib/nr/nr.o] Error 1
Solution-----------<
--- ns-2.1b9a/diffusion3/lib/nr/nr.hh 2006-08-31 12:12:51.000000000 -0300
+++ ns-2.1b9a/diffusion3/lib/nr/nr.hh 2006-08-31 12:13:53.000000000 -0300
@@ -203,6 +203,7 @@
 };
 
 // string specialization
+template <>
 class NRSimpleAttribute<char *>: public NRAttribute {
 public:
   NRSimpleAttribute(int key, int type, int op, char *val, int size = 0);
@@ -218,6 +218,7 @@
 };
 
 // blob specialization
+template <>
 class NRSimpleAttribute<void *>: public NRAttribute {
 public:
   NRSimpleAttribute(int key, int type, int op, void *val, int size);
reference<-------->
http://larsis.inf.ufpr.br/maverson/

Description-------->
./diffusion3/diffusion/diffusion.hh:97: error: expected `)' before '*' token
Solution-----------<
--- ns-2.1b9a/diffusion3/diffusion/diffusion.hh 2006-08-31 11:48:37.000000000 -0300
+++ ns-2.1b9a/diffusion3/diffusion/diffusion.hh 2006-08-31 11:50:54.000000000 -0300
@@ -87,1 +87,2 @@
 class HashEntry;
+class DiffRoutingAgent;
reference<-------->
http://blog.tianya.cn/blogger/post_show.asp?idWriter=0&Key=0&BlogID=78856&PostID=9333930

Description-------->
usr/lib/gcc/i486-linux-gnu/4.1.1/../../../../include/c++/4.1 .1/bits/stl_deque.h: In member function ‘void std::_Deque_base<_Tp, _Alloc>::_M_initialize_map(size_t)’:
/usr/lib/gcc/i486-linux-gnu /4.1.1/../../../../include/c++/4.1.1/bits/stl_deque.h:469: error: expected unqualified-id before ‘(’ token
/usr/lib/gcc/i486-linux-gnu/4.1.1/../../../../include/c++/4.1 .1/bits/deque.tcc: In member function ‘void std::deque<_Tp, _Alloc>::_M_reallocate_map(size_t, bool)’:
/usr/lib/gcc/i486-linux-gnu/4.1.1/../../../../include/c++/4 .1.1/bits/deque.tcc:747: error: expected unqualified-id before ‘(’ token
/usr/lib/gcc/i486-linux-gnu/4.1.1/../../../../include/c++/4.1 .1/bits/stl_bvector.h: In member function ‘void std::vector::_M_insert_range(std::_Bit_iterator, _ForwardIterator, _ForwardIterator, std::forward_iterator_tag)’:
/usr/lib/gcc/i486-linux-gnu/4.1.1/../. ./../../include/c++/4.1.1/bits/stl_bvector.h:542: error: expected unqualified-id before ‘(’ token
/usr/lib/gcc/i486-linux-gnu/4.1.1/../../../../include/c++/4.1 .1/bits/stl_bvector.h: In member function ‘void std::vector::_M_fill_insert(std::_Bit_iterator, size_t, bool)’:
/usr/lib/gcc/i486-linux-gnu/4.1.1/../../../../include/c++/4 .1.1/bits/stl_bvector.h:897: error: expected unqualified-id before ‘(’ token
/usr/lib/gcc/i486-linux-gnu/4.1.1/../../../../include/c++/4.1 .1/bits/vector.tcc: In member function ‘void std::vector<_Tp, _Alloc>::_M_fill_insert(__gnu_cxx::__normal_iterator<_Tp, _Alloc>::_Tp_alloc_type::pointer, std::vector<_Tp, _Alloc> >, size_t, const _Tp&)’:
/usr/lib/gcc/i486-linux-gnu/4.1.1/../../../../include/c ++/4.1.1/bits/vector.tcc:353: error: expected unqualified-id before ‘(’ token
/usr/lib/gcc/i486-linux-gnu/4.1.1/../../../../include/c++/4.1 .1/bits/vector.tcc: In member function ‘void std::vector<_Tp, _Alloc>::_M_range_insert(__gnu_cxx::__normal_iterator<_Tp, _Alloc>::_Tp_alloc_type:
Solution-----------<
install gcc-3.3 and g++-3.3
then set CC=/usr/bin/gcc-3.3;CXX=/usr/bin/g++-3.3

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值