无法使用我的协议通过多跳发送TCP数据包

时间:2014-09-15 11:14:45

标签: tcp ns2

我已经为无线网络实现了名为TRLR的协议,该协议不是ad-hoc路由协议。它只允许节点在一段指定时间后发送R_UPDATE消息。一切都运行顺畅,但TCP源仅在它们处于彼此的范围内时与TCPSINK通信。我想通过尽可能最短的路径通过多跳发送这些数据包。如何在ns-2.34中完成?

请帮忙。

我的协议的转发功能。

void
TRLR::forward(RouteEntry* rt, Packet *p, double delay)
{
struct hdr_cmn *ch = HDR_CMN(p);
struct hdr_ip *ih = HDR_IP(p);

if(ih->ttl_ == 0) {

#ifdef DEBUG
fprintf(stderr, "%s: calling drop()\n", __PRETTY_FUNCTION__);
#endif // DEBUG

drop(p, DROP_RTR_TTL);
return;
}

if (ch->ptype() != PT_TRLR && ch->direction() == hdr_cmn::UP &&
((u_int32_t)ih->daddr() == IP_BROADCAST)
    || (ih->daddr() == here_.addr_)) {
dmux_->recv(p,0);
return;
}

if (rt) {
assert(rt->rt_flags == RTF_UP);
rt->rt_expire = CURRENT_TIME + ACTIVE_ROUTE_TIMEOUT;
ch->next_hop_ = rt->rt_nexthop;
ch->addr_type() = NS_AF_INET;
ch->direction() = hdr_cmn::DOWN;       //important: change the packet's direction
}

else { // if it is a broadcast packet
assert(ih->daddr() == (nsaddr_t) IP_BROADCAST);
ch->addr_type() = NS_AF_NONE;
ch->direction() = hdr_cmn::DOWN;       //important: change the packet's direction
}

if (ih->daddr() == (nsaddr_t) IP_BROADCAST) {
// If it is a broadcast packet
if (ch->ptype() != PT_TRLR) {
 Scheduler::instance().schedule(target_, p, 0.);  
}
}
else { // Not a broadcast packet 
if(delay > 0.0) {
 Scheduler::instance().schedule(target_, p, delay);
}
else {
// Not a broadcast packet, no delay, send immediately
 Scheduler::instance().schedule(target_, p, 0.);
  }
 }

}

0 个答案:

没有答案