- Timestamp:
- 10/28/09 10:26:34 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
vtcross/trunk/src/cross-examples/python/gnuradio-examples/benchmark_dsa.py
r499 r505 44 44 45 45 global sync_status,mode,ch,traffic_flag,n_rcvd, n_right 46 global ticker_start,time_right_now #measuring duration over which no packet is sent 47 ticker_start = datetime.now() 48 #no_packet_stop_time = False 49 global no_packet_period #allowed duration for no packet 50 no_packet_period = 3 46 51 sync_status = False 47 52 … … 69 74 global n_right, sync_status, mode, ch, traffic_flag 70 75 global n_attempts, return_flag, crossShellHost, crossShellPort 71 76 global ticker_start,time_right_now,no_packet_period 77 78 72 79 n_rcvd = 0 73 80 n_right = 0 … … 168 175 def rx_callback(ok, payload): 169 176 170 global n_rcvd, n_right,sync_status,mode,ch,traffic_flag 177 global n_rcvd, n_right,sync_status,mode,ch,traffic_flag,ticker_start 178 179 ticker_start = datetime.now() 180 #print "inside callback" 181 #print "ticker_start ",ticker_start 171 182 ########################## sync #################################### 172 183 if mode == "sync": … … 190 201 ######################### traffic ################################# 191 202 if mode == "traffic": 203 204 205 206 192 207 if ok: 193 208 (data_header,) = struct.unpack('!s', payload[0]) … … 314 329 315 330 # build the graph 316 331 print "printing modulation scheme",demods[options_rx.modulation] 317 332 tb = my_top_block(mods[options_tx.modulation], 318 333 demods[options_rx.modulation], … … 331 346 332 347 # Scan all channels first for inital data 333 time.sleep(0.1)348 #time.sleep(0.1) 334 349 335 350 print "\n[[ Scanning channels for network nodes ]]\n" … … 416 431 continue 417 432 418 ch_energy = tb.rxpath.probe.level() #check if primary user is present 419 420 if int(ch_energy) > 1.5e8: #if primary user is there then dont transmit on this channel 421 stop_time = datetime.now() 422 _elapsed_time = start_time - stop_time 423 elapsed_time = _elapsed_time.seconds 424 print "\n[[ Primary User Detected: Evacuating Current Channel ]]\n" 425 print "\n[[ Scanning channels for network nodes ]]\n" 426 mode = "sync" 427 return_flag = 1 433 #ch_energy = tb.rxpath.probe.level() #check if primary user is present 434 time_right_now = datetime.now() 435 #print "inside traffic , ticker_start",ticker_start 436 packet_delay = (time_right_now - ticker_start).seconds 437 #print "packet_delay ",packet_delay 438 if packet_delay >= no_packet_period: 439 stop_time = datetime.now() 440 _elapsed_time = start_time - stop_time 441 elapsed_time = _elapsed_time.seconds 442 print "\n[[ No data packets: Evacuating Current Channel ]]\n" 443 print "\n[[ Scanning channels for network nodes ]]\n" 444 mode = "sync" 445 mode = "sync" 446 return_flag = 1 447 448 449 #if int(ch_energy) > 1.5e8: #if primary user is there then dont transmit on this channel 450 428 451 429 452