Changeset 549
- Timestamp:
- 04/27/08 16:57:35 (3 weeks ago)
- Files:
-
- nano-RK/projects/SAMPL/app_pkt_handlers/neighbor_pkt.c (modified) (4 diffs)
- nano-RK/projects/SAMPL/app_pkt_handlers/neighbor_pkt.h (modified) (1 diff)
- nano-RK/projects/SAMPL/app_pkt_handlers/stats_pkt.c (modified) (1 diff)
- nano-RK/projects/SAMPL/app_pkt_handlers/trace.c (modified) (1 diff)
- nano-RK/projects/SAMPL/client/aggregate.c (modified) (1 diff)
- nano-RK/projects/SAMPL/client/generate.c (modified) (1 diff)
- nano-RK/projects/SAMPL/client/main.c (modified) (5 diffs)
- nano-RK/projects/SAMPL/client/makefile (modified) (2 diffs)
- nano-RK/projects/SAMPL/client/nrk_cfg.h (modified) (1 diff)
- nano-RK/projects/SAMPL/include/sampl.h (modified) (2 diffs)
- nano-RK/src/net/neighbor_list (added)
- nano-RK/src/net/neighbor_list/neighbor_list.c (added)
- nano-RK/src/net/neighbor_list/neighbor_list.h (added)
- nano-RK/src/net/route_table/route_table.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
nano-RK/projects/SAMPL/app_pkt_handlers/neighbor_pkt.c
r548 r549 2 2 #include <../include/sampl.h> 3 3 #include <neighbor_pkt.h> 4 #include <route_table.h>5 4 6 5 #ifdef NANORK … … 8 7 #include <nrk_error.h> 9 8 #include <debug.h> 9 #include <neighbor_list.h> 10 10 #else 11 11 #define my_mac 0 … … 20 20 NLIST_PKT_T p; 21 21 int8_t i,cnt; 22 uint16_t n;23 22 24 _route_table_ttl_update(); 25 23 neighbor_list_ttl_update(); 26 24 cnt=0; 27 25 i=0; 28 while(1) 26 27 do 29 28 { 30 29 p.mac_addr=my_mac; 31 i= route_table_get_next_valid_index(0);30 i=neighbor_list_get_next_valid_index(i); 32 31 if(i==NRK_ERROR) break; 33 n=route_table_get_dst_by_index(i); 32 p.neighbor_mac=neighbor_list_get_mac(i); 33 p.rssi=neighbor_list_get_rssi(i); 34 34 i++; 35 pkt->payload_len = nlist_pkt_add( &p, pkt->payload,cnt); 35 36 cnt++; 36 p.neighbor_mac=route_table_get(n);37 p.rssi=route_table_value_get(n,0);38 pkt->payload_len = nlist_pkt_add( &p, pkt->payload,0);39 37 pkt->num_msgs=cnt; 40 } 38 } while(i!=NRK_ERROR); 41 39 42 40 if(cnt==0) … … 54 52 NLIST_PKT_T p1, p2; 55 53 56 if(in->next_hop_dst_mac!=my_mac ) nrk_kprintf( PSTR( "aggregating bad packet!\r\n" ));54 //if(in->next_hop_dst_mac!=my_mac ) nrk_kprintf( PSTR( "aggregating bad packet!\r\n" )); 57 55 for(i=0; i<in->num_msgs; i++ ) 58 56 { nano-RK/projects/SAMPL/app_pkt_handlers/neighbor_pkt.h
r548 r549 1 #ifndef _ STATS_PKT_H2 #define _ STATS_PKT_H1 #ifndef _NLIST_PKT_H 2 #define _NLIST_PKT_H 3 3 4 4 #ifdef NANORK nano-RK/projects/SAMPL/app_pkt_handlers/stats_pkt.c
r548 r549 38 38 STATS_PKT_T p1, p2; 39 39 40 if(in->next_hop_dst_mac!=my_mac ) nrk_kprintf( PSTR( "aggregating bad packet!\r\n" ));40 //if(in->next_hop_dst_mac!=my_mac ) nrk_kprintf( PSTR( "aggregating bad packet!\r\n" )); 41 41 for(i=0; i<in->num_msgs; i++ ) 42 42 { nano-RK/projects/SAMPL/app_pkt_handlers/trace.c
r548 r549 24 24 TRACE_PKT_T p1, p2; 25 25 26 if(in->next_hop_dst_mac!=my_mac ) nrk_kprintf( PSTR( "aggregating bad packet!\r\n" ));26 // if(in->next_hop_dst_mac!=my_mac ) nrk_kprintf( PSTR( "aggregating bad packet!\r\n" )); 27 27 for(i=0; i<in->num_msgs; i++ ) 28 28 { nano-RK/projects/SAMPL/client/aggregate.c
r548 r549 55 55 break; 56 56 57 case NEIGHBOR_LIST_PKT:57 case SUBNET_NEIGHBOR_LIST_PKT: 58 58 nlist_aggregate(us_pkt_in, us_pkt ); 59 59 break; nano-RK/projects/SAMPL/client/generate.c
r548 r549 85 85 break; 86 86 87 case NEIGHBOR_LIST_PKT:87 case SUBNET_NEIGHBOR_LIST_PKT: 88 88 nlist_generate(us_pkt,ds_pkt); 89 89 break; nano-RK/projects/SAMPL/client/main.c
r548 r549 42 42 #include <nrk_eeprom.h> 43 43 #include <route_table.h> 44 #include <neighbor_list.h> 44 45 #include <debug.h> 45 46 … … 183 184 route_table_init(); 184 185 185 // Default neighbor list TTL is 10 minutes 186 // initialize the neighbor list 187 neighbor_list_init(); 188 189 // Default neighbor list TTL is 10 minutes 186 190 neighborlist_ttl=600; 187 191 … … 353 357 } 354 358 // This is a NEW downstream flood packet 355 else if ((ff_state == IDLE_STATE) && (downstream == 1) 356 && (ds_pkt.seq_num != last_flood_seq_num) && check_subnet(p2p_pkt_in.subnet_mac, my_subnet_mac )==1 ) { 359 else if (downstream == 1 && check_subnet(p2p_pkt_in.subnet_mac, my_subnet_mac )==1 ) { 360 // Got downstream message from someone in subnet, so add to neighbor list 361 neighbor_list_add( ds_pkt.last_hop_mac, ds_pkt.rssi, neighborlist_ttl ); 362 363 // We actually need to service this downstream message 364 if(ff_state== IDLE_STATE && ds_pkt.seq_num != last_flood_seq_num) { 357 365 last_flood_pkt = ds_pkt.pkt_type; 358 366 last_flood_check_rate = ds_pkt.mac_check_rate; … … 363 371 // Set the reply address for the gateway (mac=0) to last-hop with no ttl timeout 364 372 route_table_set( GATEWAY_MAC, ds_pkt.last_hop_mac, 0 ); 365 // Add neighbor, with timeout 366 route_table_set( ds_pkt.last_hop_mac, ds_pkt.last_hop_mac, neighborlist_ttl ); 367 // Insert RSSI from neighbor 368 route_table_value_set(ds_pkt.last_hop_mac, 0, ds_pkt.rssi ); 373 369 374 370 375 if(ds_pkt.ctrl_flags & ENCRYPT != 0) … … 391 396 } 392 397 } 398 } 393 399 // Upstream Packet to Aggregate 394 400 else if (ff_state == FLOOD_ACTIVE_STATE && upstream == 1) { 395 // Add neighbor, with timeout 396 route_table_set( us_pkt.last_hop_src_mac, us_pkt.last_hop_src_mac, neighborlist_ttl ); 397 // Insert RSSI from neighbor 398 route_table_value_set(us_pkt.last_hop_src_mac, 0, us_pkt.rssi ); 401 // Add neighbor, with timeout 402 neighbor_list_add( us_pkt_in.last_hop_src_mac, us_pkt_in.rssi, neighborlist_ttl ); 399 403 400 404 if ( us_pkt_in.seq_num == last_flood_seq_num && check_subnet( us_pkt_in.subnet_mac, my_subnet_mac)==1 ) { nano-RK/projects/SAMPL/client/makefile
r544 r549 46 46 # For example: 47 47 SRC += $(ROOT_DIR)/src/net/route_table/route_table.c 48 SRC += $(ROOT_DIR)/src/net/neighbor_list/neighbor_list.c 48 49 SRC += $(ROOT_DIR)/src/net/bmac/bmac.c 49 50 SRC += $(ROOT_DIR)/src/drivers/platform/$(PLATFORM_TYPE)/source/ff_basic_sensor.c … … 56 57 EXTRAINCDIRS += $(ROOT_DIR)/src/net/bmac 57 58 EXTRAINCDIRS += $(ROOT_DIR)/src/net/route_table 59 EXTRAINCDIRS += $(ROOT_DIR)/src/net/neighbor_list 58 60 59 61 nano-RK/projects/SAMPL/client/nrk_cfg.h
r544 r549 46 46 #define NRK_MAX_RESOURCE_CNT 2 47 47 48 #define ROUTE_TABLE_SIZE 15 48 #define NEIGHBOR_LIST_SIZE 15 49 #define ROUTE_TABLE_SIZE 5 49 50 #define ROUTE_TABLE_VALUES 1 50 51 nano-RK/projects/SAMPL/include/sampl.h
r548 r549 78 78 79 79 // PKT Types 80 #define EMPTY_PKT 0x00 81 #define PING_PKT 0x01 82 #define WIRELESS_UPDATE_PKT 0x02 83 #define ACK_PKT 0x03 84 #define ERROR_PKT 0x04 85 #define ROUTE_PKT 0x05 86 #define FF_SENSOR_LONG_PKT 0x06 87 #define FF_SENSOR_SHORT_PKT 0x07 88 #define TRACEROUTE_PKT 0x08 89 #define CONTROL_PKT 0x09 90 #define LED_CONTROL_PKT 0x0A 91 #define DATA_STORAGE_PKT 0X0B 92 #define XMPP_PKT 0X0C 93 #define STATS_PKT 0X0D 94 #define NEIGHBOR_LIST_PKT 0X0E 95 #define UNKNOWN_PKT 0X0F 80 #define EMPTY_PKT 0x00 81 #define PING_PKT 0x01 82 #define WIRELESS_UPDATE_PKT 0x02 83 #define ACK_PKT 0x03 84 #define ERROR_PKT 0x04 85 #define ROUTE_PKT 0x05 86 #define FF_SENSOR_LONG_PKT 0x06 87 #define FF_SENSOR_SHORT_PKT 0x07 88 #define TRACEROUTE_PKT 0x08 89 #define CONTROL_PKT 0x09 90 #define LED_CONTROL_PKT 0x0a 91 #define DATA_STORAGE_PKT 0X0b 92 #define XMPP_PKT 0X0c 93 #define STATS_PKT 0X0d 94 #define SUBNET_NEIGHBOR_LIST_PKT 0X0e 95 #define FULL_NEIGHBOR_LIST_PKT 0X0f 96 #define UNKNOWN_PKT 0X10 96 97 // UNKNOWN_PKT used by phoenix etc, do not remove 97 98 … … 268 269 uint8_t last_hop_mac; 269 270 uint8_t next_hop_mac; 271 // uint8_t reply_checkrate; 270 272 271 273 nano-RK/src/net/route_table/route_table.c
r544 r549 29 29 nrk_time_get(¤t_time); 30 30 v=nrk_time_sub(&elapsed_time, current_time, last_time); 31 last_time.secs=current_time.secs; 32 last_time.nano_secs=current_time.nano_secs; 31 33 if(v==NRK_OK) 32 34 { … … 150 152 { 151 153 uint8_t i; 152 if(start_index>=ROUTE_TABLE_ VALUES) return NRK_ERROR;154 if(start_index>=ROUTE_TABLE_SIZE) return NRK_ERROR; 153 155 for(i=start_index; i<ROUTE_TABLE_SIZE; i++ ) 154 156 if((route_table[i].flags & VALID_MASK) !=0 ) … … 159 161 uint16_t route_table_get_dst_by_index(int8_t index) 160 162 { 161 if(index>=ROUTE_TABLE_ VALUES) return 0;163 if(index>=ROUTE_TABLE_SIZE ) return 0; 162 164 return route_table[index].dst; 163 165
