From: bg <bg...@us...> - 2007-04-30 15:28:03
|
Update of /cvsroot/contiki/contiki-2.x/core/net In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv29654 Modified Files: uaodv.c Log Message: * Set route timeout to maximum value for std compliance. * Rename aodvconn to bcastconn for clarity and uniformity. * Use uip_udp_packet_send where possible. * Change a lot of debug printfs. * Moved call to fwc_add. * Set ttl to sensible value if AODV_COMPLIANCE. Index: uaodv.c =================================================================== RCS file: /cvsroot/contiki/contiki-2.x/core/net/uaodv.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** uaodv.c 30 Apr 2007 09:49:32 -0000 1.11 --- uaodv.c 30 Apr 2007 15:26:09 -0000 1.12 *************** *** 51,59 **** #endif ! #define MY_ROUTE_TIMEOUT 0 PROCESS(uaodv_process, "uAODV"); ! static struct uip_udp_conn *aodvconn, *unicastconn; /* Compare sequence numbers as per RFC 3561. */ --- 51,60 ---- #endif ! /* This implementation never expires routes!!! */ ! #define MY_ROUTE_TIMEOUT ((u16_t)~0u) PROCESS(uaodv_process, "uAODV"); ! static struct uip_udp_conn *bcastconn, *unicastconn; /* Compare sequence numbers as per RFC 3561. */ *************** *** 139,143 **** uip_ipaddr_copy(&unicastconn->ripaddr, dest); uip_udp_conn = unicastconn; ! uip_send(buf, len); } /*---------------------------------------------------------------------------*/ --- 140,144 ---- uip_ipaddr_copy(&unicastconn->ripaddr, dest); uip_udp_conn = unicastconn; ! uip_udp_packet_send(unicastconn, buf, len); } /*---------------------------------------------------------------------------*/ *************** *** 155,163 **** rm->rreq_id = htonl(rreq_id++); uip_ipaddr_copy(&rm->dest_addr, addr); ! rm->dest_seqno = 0; uip_gethostaddr(&rm->orig_addr); rreq_seqno++; /* Always */ rm->orig_seqno = htonl(rreq_seqno); ! uip_send((char *)rm, sizeof(struct uaodv_msg_rreq)); } /*---------------------------------------------------------------------------*/ --- 156,164 ---- rm->rreq_id = htonl(rreq_id++); uip_ipaddr_copy(&rm->dest_addr, addr); ! rm->dest_seqno = 0; /* UNKSEQNO */ uip_gethostaddr(&rm->orig_addr); rreq_seqno++; /* Always */ rm->orig_seqno = htonl(rreq_seqno); ! uip_udp_packet_send(bcastconn, rm, sizeof(struct uaodv_msg_rreq)); } /*---------------------------------------------------------------------------*/ *************** *** 180,185 **** rm->lifetime = HTONL(MY_ROUTE_TIMEOUT); sendto(nexthop, rm, sizeof(struct uaodv_msg_rrep)); - - print_debug("Sending RREP to %d.%d.%d.%d\n", uip_ipaddr_to_quad(nexthop)); } /*---------------------------------------------------------------------------*/ --- 181,184 ---- *************** *** 189,192 **** --- 188,193 ---- struct uaodv_msg_rerr *rm = (struct uaodv_msg_rerr *)uip_appdata; + print_debug("send RERR for %d.%d.%d.%d\n", uip_ipaddr_to_quad(addr)); + rm->type = UAODV_RERR_TYPE; rm->flags = 0; *************** *** 196,203 **** rm->unreach[0].seqno = *seqno; ! sendto(&uip_broadcast_addr, rm, sizeof(struct uaodv_msg_rerr)); ! ! print_debug("Broadcasting initial RERR for %d.%d.%d.%d\n", ! uip_ipaddr_to_quad(addr)); } /*---------------------------------------------------------------------------*/ --- 197,201 ---- rm->unreach[0].seqno = *seqno; ! uip_udp_packet_send(bcastconn, rm, sizeof(struct uaodv_msg_rerr)); } /*---------------------------------------------------------------------------*/ *************** *** 208,224 **** uip_ipaddr_t dest_addr, orig_addr; struct uaodv_rt_entry *rt, *fw = NULL; #ifdef CC2420_RADIO if(cc2420_last_rssi <= -38 || cc2420_last_correlation < 100) { ! print_debug("RREQ drop from %d.%d.%d.%d %d %d \n", ! uip_ipaddr_to_quad(uip_udp_sender()), ! cc2420_last_rssi, ! cc2420_last_correlation); return; } if(cc2420_check_remote(uip_udp_sender()->u16[1]) == REMOTE_YES) { ! print_debug("RREQ drop from %d.%d.%d.%d is remote\n", ! uip_ipaddr_to_quad(uip_udp_sender())); return; } --- 206,227 ---- uip_ipaddr_t dest_addr, orig_addr; struct uaodv_rt_entry *rt, *fw = NULL; + + print_debug("RREQ %d.%d.%d.%d -> %d.%d.%d.%d ttl=%u" + " orig=%d.%d.%d.%d seq=%lu hops=%u dest=%d.%d.%d.%d seq=%lu\n", + uip_ipaddr_to_quad(&BUF->srcipaddr), + uip_ipaddr_to_quad(&BUF->destipaddr), + BUF->ttl, + uip_ipaddr_to_quad(&rm->orig_addr), ntohl(rm->orig_seqno), + rm->hop_count, + uip_ipaddr_to_quad(&rm->dest_addr), ntohl(rm->dest_seqno)); #ifdef CC2420_RADIO if(cc2420_last_rssi <= -38 || cc2420_last_correlation < 100) { ! print_debug("RREQ drop %d %d\n", cc2420_last_rssi,cc2420_last_correlation); return; } if(cc2420_check_remote(uip_udp_sender()->u16[1]) == REMOTE_YES) { ! print_debug("RREQ drop is remote\n"); return; } *************** *** 228,237 **** if(uip_ipaddr_cmp(&rm->orig_addr, &uip_hostaddr) || fwc_lookup(&rm->orig_addr, &rm->rreq_id)) { ! print_debug("Not fwd rreq from %d.%d.%d.%d orig_addr %d.%d.%d.%d, rreq_id %lu\n", ! uip_ipaddr_to_quad(uip_udp_sender()), ! uip_ipaddr_to_quad(&rm->orig_addr), ! ntohl(rm->rreq_id)); return; } /* New reverse route? */ --- 231,238 ---- if(uip_ipaddr_cmp(&rm->orig_addr, &uip_hostaddr) || fwc_lookup(&rm->orig_addr, &rm->rreq_id)) { ! print_debug("Not fwd rreq\n"); return; } + fwc_add(&rm->orig_addr, &rm->rreq_id); /* New reverse route? */ *************** *** 241,249 **** || (SCMP32(ntohl(rm->orig_seqno), rt->seqno) == 0 && rm->hop_count < rt->hop_count)) { /* Better route. */ ! print_debug("Inserting1 %d.%d.%d.%d into routing table, next hop %d.%d.%d.%d, hop_count %u seq %lu\n", ! uip_ipaddr_to_quad(&rm->orig_addr), ! uip_ipaddr_to_quad(uip_udp_sender()), ! rm->hop_count, ! ntohl(rm->orig_seqno)); rt = uaodv_rt_add(&rm->orig_addr, uip_udp_sender(), rm->hop_count, ntohl(rm->orig_seqno)); --- 242,246 ---- || (SCMP32(ntohl(rm->orig_seqno), rt->seqno) == 0 && rm->hop_count < rt->hop_count)) { /* Better route. */ ! print_debug("Inserting1\n"); rt = uaodv_rt_add(&rm->orig_addr, uip_udp_sender(), rm->hop_count, ntohl(rm->orig_seqno)); *************** *** 253,258 **** if(uip_ipaddr_cmp(&rm->dest_addr, &uip_hostaddr) || (fw = uaodv_rt_lookup(&rm->dest_addr)) != NULL) { ! print_debug("RREQ for known address %d.%d.%d.%d\n", ! uip_ipaddr_to_quad(&rm->dest_addr)); /* Send an RREP back to the source of the RREQ. */ uip_ipaddr_copy(&dest_addr, &rm->dest_addr); --- 250,254 ---- if(uip_ipaddr_cmp(&rm->dest_addr, &uip_hostaddr) || (fw = uaodv_rt_lookup(&rm->dest_addr)) != NULL) { ! print_debug("RREQ for known address\n"); /* Send an RREP back to the source of the RREQ. */ uip_ipaddr_copy(&dest_addr, &rm->dest_addr); *************** *** 266,277 **** } } else { ! print_debug("RREQ for %d.%d.%d.%d orig %d.%d.%d.%d ttl=%d\n", ! uip_ipaddr_to_quad(&rm->dest_addr), ! uip_ipaddr_to_quad(&rm->orig_addr), ! uip_udp_conn->ttl); ! ! fwc_add(&rm->orig_addr, &rm->rreq_id); rm->hop_count++; ! uip_send(rm, sizeof(struct uaodv_msg_rreq)); } } --- 262,268 ---- } } else { ! print_debug("RREQ fwd\n"); rm->hop_count++; ! uip_udp_packet_send(bcastconn, rm, sizeof(struct uaodv_msg_rreq)); } } *************** *** 283,286 **** --- 274,285 ---- struct uaodv_rt_entry *rt; + print_debug("RREP %d.%d.%d.%d -> %d.%d.%d.%d" + " dest=%d.%d.%d.%d seq=%lu hops=%u orig=%d.%d.%d.%d\n", + uip_ipaddr_to_quad(&BUF->srcipaddr), + uip_ipaddr_to_quad(&BUF->destipaddr), + uip_ipaddr_to_quad(&rm->dest_addr), ntohl(rm->dest_seqno), + rm->hop_count, + uip_ipaddr_to_quad(&rm->orig_addr)); + rt = uaodv_rt_lookup(&rm->dest_addr); *************** *** 290,298 **** /* New forward route? */ if(rt == NULL || (SCMP32(ntohl(rm->dest_seqno), rt->seqno) > 0)) { ! print_debug("Inserting3 %d.%d.%d.%d into routing table, next hop %d.%d.%d.%d, hop_count %u seq %lu.\n", ! uip_ipaddr_to_quad(&rm->dest_addr), ! uip_ipaddr_to_quad(uip_udp_sender()), ! rm->hop_count, ! ntohl(rm->dest_seqno)); rt = uaodv_rt_add(&rm->dest_addr, uip_udp_sender(), rm->hop_count, ntohl(rm->dest_seqno)); --- 289,293 ---- /* New forward route? */ if(rt == NULL || (SCMP32(ntohl(rm->dest_seqno), rt->seqno) > 0)) { ! print_debug("Inserting3\n"); rt = uaodv_rt_add(&rm->dest_addr, uip_udp_sender(), rm->hop_count, ntohl(rm->dest_seqno)); *************** *** 300,314 **** /* This link is ok since he is unicasting back to us! */ cc2420_recv_ok(uip_udp_sender()); ! print_debug("RREP recv ok from %d.%d.%d.%d %d %d \n", ! uip_ipaddr_to_quad(uip_udp_sender()), ! cc2420_last_rssi, ! cc2420_last_correlation); #endif } else { ! print_debug("Not inserting %d.%d.%d.%d into routing table, next hop %d.%d.%d.%d, hop_count %d.\n", ! uip_ipaddr_to_quad(&rm->dest_addr), ! uip_ipaddr_to_quad(uip_udp_sender()), ! rm->hop_count); ! } --- 295,303 ---- /* This link is ok since he is unicasting back to us! */ cc2420_recv_ok(uip_udp_sender()); ! print_debug("RREP recv ok %d %d\n", ! cc2420_last_rssi, cc2420_last_correlation); #endif } else { ! print_debug("Not inserting\n"); } *************** *** 343,349 **** struct uaodv_rt_entry *rt; ! print_debug("RERR received from %d.%d.%d.%d route to %d.%d.%d.%d seq=%lu\n", ! uip_ipaddr_to_quad(uip_udp_sender()), ! uip_ipaddr_to_quad(&rm->unreach[0].addr), ntohl(rm->unreach[0].seqno)); --- 332,340 ---- struct uaodv_rt_entry *rt; ! print_debug("RERR %d.%d.%d.%d -> %d.%d.%d.%d" ! " unreach=%d.%d.%d.%d seq=%lu\n", ! uip_ipaddr_to_quad(&BUF->srcipaddr), ! uip_ipaddr_to_quad(&BUF->destipaddr), ! uip_ipaddr_to_quad((uip_ipaddr_t *)&rm->unreach[0]), ntohl(rm->unreach[0].seqno)); *************** *** 354,358 **** uaodv_rt_remove(rt); print_debug("RERR rebroadcast\n"); ! sendto(&uip_broadcast_addr, rm, sizeof(struct uaodv_msg_rerr)); } } --- 345,349 ---- uaodv_rt_remove(rt); print_debug("RERR rebroadcast\n"); ! uip_udp_packet_send(bcastconn, rm, sizeof(struct uaodv_msg_rerr)); } } *************** *** 437,442 **** printf("uaodv_process starting\n"); ! aodvconn = udp_broadcast_new(HTONS(UAODV_UDPPORT), NULL); ! aodvconn->ttl = 1; unicastconn = udp_broadcast_new(HTONS(UAODV_UDPPORT), NULL); unicastconn->ttl = 1; --- 428,437 ---- printf("uaodv_process starting\n"); ! bcastconn = udp_broadcast_new(HTONS(UAODV_UDPPORT), NULL); ! #ifdef AODV_COMPLIANCE ! bcastconn->ttl = 6; ! #else ! bcastconn->ttl = 1; ! #endif unicastconn = udp_broadcast_new(HTONS(UAODV_UDPPORT), NULL); unicastconn->ttl = 1; *************** *** 468,472 **** PROCESS_WAIT_UNTIL(etimer_expired(&etimer)); #endif ! tcpip_poll_udp(aodvconn); } } --- 463,467 ---- PROCESS_WAIT_UNTIL(etimer_expired(&etimer)); #endif ! tcpip_poll_udp(bcastconn); } } *************** *** 475,480 **** command = COMMAND_NONE; uaodv_rt_flush_all(); ! uip_udp_remove(aodvconn); ! aodvconn = NULL; uip_udp_remove(unicastconn); unicastconn = NULL; --- 470,475 ---- command = COMMAND_NONE; uaodv_rt_flush_all(); ! uip_udp_remove(bcastconn); ! bcastconn = NULL; uip_udp_remove(unicastconn); unicastconn = NULL; |