ns2.30下添加mflood源码

    技术2022-07-02  98

    一、需要的mflood源码:mflood.cc,mflood.h,mflood-seqtable.cc,mflood-seqtable.h,mflood-packet.h

    二、具体过程:

    1、在ns-2.30目录下建立mflood文件夹,把上述文件统统放进去。2、 修改 ns-lib.tcl(在ns2.30/tcl/lib/):(红色表示添加部分 )OMNIMCAST {    eval $node addr $args     set ragent [$self create-omnimcast-agent $node] } MFlood {     set ragent [$self create-mflood-agent $node] } DumbAgent {     set ragent [$self create-dumb-agent $node] } 另外在空白处加入:Simulator instproc create-tora-agent { node } {     set ragent [new Agent/TORA [$node id]]     $node set ragent_ $ragent     return $ragent }

    (上面的部分原来的书里面没有,在测试时发现ns node生成时出错,因此按照这里修改了以上部分) Simulator instproc create-mflood-agent {node} {     set ragent [new Agent/MFlood [$node id]]     $node set ragent_ $ragent     return $ragent }3、修改ns-packet.tcl(在ns2.30/tcl/lib/ ): foreach prot {     ...    MFlood     AODV    ...} 4、修改 packet.h(在ns2.30/common/):enum packet_t {     ⋯⋯     PT_AODV,     PT_MFLOOD,     ⋯⋯ } p_info() {     ⋯⋯     name_[PT_AODV]= "AODV";     name_[PT_MFLOOD]="MFlood";     ⋯⋯ } 5、修改 Makefile(在ns2.30/)在 OBJ_CC 中增加一行:mflood/mflood.o mflood/mflood-seqtable.o / 6、在mflood.cc(在刚建立的文件加ns2.30/mflood/)中加入 :        ...        uptarget_ = (NsObject*)TclObject::lookup(argv[2]);         if (uptarget_ == 0) {             tcl.resultf("no such object %s", argv[2]);              return (TCL_ERROR);          }         return (TCL_OK);         }

            else if (strcasecmp (argv[1], "port-dmux") == 0) {              TclObject *obj;             port_dmux_ = (NsObject *) obj;             return TCL_OK;         }    }     return Agent::command(argc, argv); } 并且修改:MFlood::MFlood(nsaddr_t id) : Agent(PT_MFLOOD) , port_dmux_(0) {      index_ = id;     logtarget = 0;     myseq_ = 0; }

     

    7、修改 mflood.h(在ns2.30/mflood/): NsObject *uptarget_; NsObject *port_dmux_; 8、在ns2.30/下make,可能会有一些warning,不用去管它。


    最新回复(0)