Changeset 505

Show
Ignore:
Timestamp:
10/28/09 10:26:34 (15 years ago)
Author:
sriram
Message:

Few changes for measuring no packet time

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • vtcross/trunk/src/cross-examples/python/gnuradio-examples/benchmark_dsa.py

    r499 r505  
    4444 
    4545global sync_status,mode,ch,traffic_flag,n_rcvd, n_right 
     46global ticker_start,time_right_now #measuring duration over which no packet is sent 
     47ticker_start = datetime.now() 
     48#no_packet_stop_time = False 
     49global no_packet_period #allowed duration for no packet 
     50no_packet_period = 3 
    4651sync_status = False 
    4752 
     
    6974    global n_right, sync_status, mode, ch, traffic_flag 
    7075    global n_attempts, return_flag, crossShellHost, crossShellPort 
    71  
     76    global ticker_start,time_right_now,no_packet_period 
     77 
     78    
    7279    n_rcvd = 0 
    7380    n_right = 0 
     
    168175    def rx_callback(ok, payload): 
    169176         
    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 
    171182        ########################## sync #################################### 
    172183        if mode == "sync": 
     
    190201        ######################### traffic ################################# 
    191202        if mode == "traffic": 
     203         
     204         
     205         
     206                 
    192207            if ok:  
    193208                (data_header,) = struct.unpack('!s', payload[0]) 
     
    314329         
    315330    # build the graph 
    316  
     331        print "printing modulation scheme",demods[options_rx.modulation] 
    317332    tb = my_top_block(mods[options_tx.modulation], 
    318333                      demods[options_rx.modulation], 
     
    331346        
    332347    # Scan all channels first for inital data 
    333     time.sleep(0.1) 
     348    #time.sleep(0.1) 
    334349 
    335350    print "\n[[ Scanning channels for network nodes ]]\n" 
     
    416431                        continue 
    417432 
    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                 
    428451                 
    429452