今天系统重装,所有得都要重来,上回自己都忘了怎么把mudp那些给弄进去得,找到当初得那个示范网页,一步一步来,发现老是在make clean;make那出问题,郁闷。想了半天,发现那大哥得教程(准备写一个NS2 step by step,NS2 by Step (2) )写得不对,下面把柯老师得教程补充详细了贴上来,以防自己再忘记,如果有童鞋能看到,也不错
1. Downloadmudp.cc,mudp.h,mudpsink.cc, and mudpsink.h(我这不带链接)
2. Create a folder named measure under ns. (for example, ~/ns-allinone-2.28/ns-2.28/measure)(就放在这个路径吧,其他我没有试过)
3. Put these four files into measure folder.
4. add sendtime_, pkt_id_ into packet common header. (modify common/packet.h)
struct hdr_cmn {
enum dir_t { DOWN= -1, NONE= 0, UP= 1 };
packet_t ptype_; // packet type (see above)
int size_; // simulated packet size
int uid_; // unique id
int error_; // error flag
int errbitcnt_; // # of corrupted bits jahn
int fecsize_;
double ts_; // timestamp: for q-delay measurement
int iface_; // receiving interface (label)
dir_t direction_; // direction: 0=none, 1=up, -1=down
double sendtime_; ...
unsigned long int pkt_id_;(添加得)
...
inline int& addr_type() { return (addr_type_); }
inline int& num_forwards() { return (num_forwards_); }
inline int& opt_num_forwards() { return (opt_num_forwards_); }
//monarch_end
inline double& sendtime() { return (sendtime_); } // added by smallko(添加得)
}
5. Add the “measure/mudp.o measure/mudpsink.o “ in the OBJ_CC of Makefile.(路径:ns-allinone-2.2x/ns-2.2x,不是ns~/ns-allinone-2.2x/nam-1.1x/)
6. Add “Agent/mUDP set packetSize_ 1000” in the ns-default.tcl. (ns-default.tcl is under ~/ns-allinone-2.28/ns-2.28/tcl/lib)
7. make clean ; make(要在路径ns-allinone-2.2x/ns-2.2x下)
就是5和7把我折腾了很久