定时器到期时ns2重新广播数据包

时间:2017-07-26 09:00:01

标签: timer ns2

我需要在等待计时器到期时重新广播数据包,我按照How to add timer in aodv using ns2定义的步骤,我定义代理和计时器类;交叉参考;在代理构造函数中初始化timer对象;并最终为B_suppression类过期(事件*)。当执行到达时     agent->rebroadcast((Packet*)p, 0);它会中止以下消息'无效的SDVCAST数据包类型'。从事件转发到数据包会导致问题吗?

class SDVCAST;

class B_suppression_Timer : public TimerHandler {
    friend class SDVCAST;
public:
    B_suppression_Timer (SDVCAST *s){agent = s;};
    virtual void expire (Event *p);
private:
    SDVCAST *agent;
};

class SDVCAST: public Agent
{ //define object from timer  
  B_suppression_Timer  bstimer;
}
//initialized timer in Constructor of the SDVCAST
SDVCAST::SDVCAST(nsaddr_t id) : Agent(PT_SDVCAST),
                bstimer(this){
}

// start timer
void
SDVCAST::weightepersistence(Packet *p, double delay){
  bstimer.resched(delay);
}


// define expire of bstimer
void
B_suppression_Timer::expire(Event *p){
    agent->rebroadcast((Packet*)p, 0);
}

1 个答案:

答案 0 :(得分:0)

将新数据包类型PT_SDVCAST添加到common/packet.h

static const packet_t PT_ SDVCAST = 73;

        // insert new packet types here
static packet_t       PT_NTYPE = 74; // This MUST be the LAST one
.
.

                type == PT_SDVCAST)

.
.           
               name_[PT_SDVCAST]= "SDVCAST"

可能会将SDVCAST添加到tcl/lib/ns-packet.tclns-default.tclns-agent.tcl等。

编辑:回答"分段错误"

  

" NS2的分组数据结构的实现不是数学   现实。 ns2模拟中的数据包保留所有数据包标头   对于在NS2中实现的任何协议。例如,DSR路由   数据包可以保留DSDV,AODV甚至PING应用程序头。对于   这个原因,直到今天,在ns2模拟中使用的数据包才会有   标题大小约为40~64KB。并且将删除NO数据包以释放   直到模拟结束它的存储器。所以对于一个典型的   模拟在ns2中的100个节点周围交换了1M个数据包   当然,您可以重用已经释放的数据包   包::免费(分组*)。要了解它的实现,请检查   文件common / packet {.h,.cc}),你可以保存10%,100K包,   并且您可以使用至少100K * 64KB的存储器 - > 6.4GB,绝对是   会崩溃您的计算机(即使它是超级服务器)。"

等。等。http://www.linuxquestions.org/questions/linux-networking-3/ns2-and-aqua-sim-4175507630/#3

http://www.linuxquestions.org/questions/tags/segmentation%20fault%20ns2/