Changeset 382

Show
Ignore:
Timestamp:
07/27/09 15:40:59 (15 years ago)
Author:
sriram
Message:

Changing logic for "i wrongly thought that we had syncd up..we havnt actually..go back to sync mode form traffic mode"

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • vtcross/branches/sriram/dsa.py

    r381 r382  
    3131def main(): 
    3232        print "inside main" 
    33         global n_rcvd, n_right,sync_status,mode,ch,traffic_flag 
     33        global n_rcvd, n_right,sync_status,mode,ch,traffic_flag,n_attempts 
    3434        n_rcvd = 0 
    3535        n_right = 0 
     36        n_attempts = 5 
    3637        def send_pkt(self, payload='', eof=False): 
    3738                return self.txpath.send_pkt(payload, eof) 
     
    257258                        else: 
    258259                                print "sync channel found..channel ",ch,"\n"   
    259                                 check_sync = 0 
     260                                n_attempts_counter = 0 
    260261                                mode = "traffic" 
    261262                                traffic_flag = False 
     
    266267                ################################################Communications mode################################# 
    267268                if mode == "traffic": 
    268                                 print "Inside traffic mode" 
    269                         if check_sync == 0: 
    270                                 time.sleep(0.8) 
    271                                 if traffic_flag != True: 
    272                                         mode = "sync" 
    273                                         continue 
    274                                 else: 
    275                                         check_sync = 1   
    276  
     269                        print "Inside traffic mode" 
     270                                         
    277271                        nbytes = 15 
    278272                        pkt_size = 15 
     
    303297                                data_pktno += 1 
    304298                                #print "before sleeping for 10 seconds and value of resend count is",resend_count 
    305                                 time.sleep(0.2) 
     299                                time.sleep(0.1 + 0.05*int(random.choice([0,1,2,3]))) 
     300 
     301                                if traffic_flag != True: 
     302                                        n_attempts_counter += 1 
     303                                        if n_attempts_counter  > n_attempts #get out of the data channel as it seems that the other node is still trying to rendezvous 
     304                                                mode = "sync" 
     305                                                continue 
     306 
    306307                                ch_energy = tb.rxpath.probe.level() #check if primary user is present 
    307308                                print "channel energy is ",ch_energy,"\n"