1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
void
LSCRUMOR::recvReply(Packet *p) {
struct hdr_cmn *ch = HDR_CMN(p);
//struct hdr_ip *ih = HDR_IP(p);
struct hdr_lscrumor_reply *rp = HDR_LSCRUMOR_REPLY(p);
lscrumor_rt_entry *rt,*rt0;
//nsaddr_t RplNextHop;
double delay = 0.0;
#ifdef DEBUG
fprintf(stderr, "%d - %s: received a REPLY\n", index, __FUNCTION__); // causes the program to exit why?
#endif // DEBUG
// Note that rp_dst is the dest of the data packets, not the
// the dest of the reply, which is the src of the data packets.
if(rp->rp_src == index)
{
rt = rtable.rt_lookup(rp->rp_dst,rp->rp_src);
rt->rt_hops = rp->rp_rt_hops;
rt->rt_Qnexthop = ch->prev_hop_;
rt->rt_flags = QUERY;
// printf("node(( %d)) recv reply and I am the source and hops = %d\n",index,rt->rt_hops);
//===========send all packet queued in the sendbuffer destine for this destination.
Packet *buf_pkt;
while((buf_pkt = rqueue.deque(rt->rt_dst)))
{// printf("node(( %d)) take data in queue to send to %d",index, rt->rt_Qnexthop);
if(rt->rt_hops != INFINITY2)
{ // printf("node(( %d)) --forward take data in queue\n",index);
forward(rt, buf_pkt, delay);
delay += ARP_DELAY;
}
}
}
else
{
rt0 = rtable.rt_lookup(rp->rp_dst,rp->rp_src);
// printf("node(( %d)) looked up route in [recvReply], and result rt = %d\n",index,rt0);
if(rt0->rt_flags == QUERY){
Packet::free(p);
return;}
//RplNextHop = rt0->rt_nexthop;
//rt0->rt_nexthop = ch->prev_hop_;
//rt0->rt_flags = QUERY;
//if((rt0->rt_src < UNKNOWN)||(rt0->rt_flags == NOTICE)||(rp->rp_rt_hops < rt0->rt_hops)) {
sendReply(rt0->rt_Nnexthop,rt0->rt_src,rt0->rt_dst,rp->rp_rt_hops+1,rt->rt_etx,1);
//if(rp->rp_rt_hops < rt0->rt_hops) printf(" &&&&&& new closer reply update route &&&&&");
//rt_update(rt0, rp->rp_rt_hops, ch->prev_hop_);
rt0->rt_hops = rp->rp_rt_hops; // ===should change the
rt0->rt_Qnexthop = ch->prev_hop_;
rt0->rt_flags = QUERY;
//printf("node(( %d)) recv reply and forward to next hop %d in $$$$$$$[recvReply]\n",index,rt0->rt_Nnexthop);
}
}
|