Changeset 365

Show
Ignore:
Timestamp:
07/23/09 11:02:27 (15 years ago)
Author:
sriram
Message:

This does not work..keeping a backup

Files:
1 modified

Legend:

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

    r359 r365  
    5454 
    5555         
    56         #print "inside rx callback" 
     56        print "inside rx callback" 
    5757        global n_rcvd, n_right, sync_status,mode,hop_freq 
    5858        #tb.rxpath.min_freq = hop_freq - 80e3  
    5959        #tb.rxpath.max_freq = hop_freq + 80e3  
    6060        #tb.rxpath.get_spec_stats(1e13,20,2) 
    61         (pktno,) = struct.unpack('!H', payload[0:2]) 
    6261        #temp = struct.unpack('!s', payload[3:10]) 
    6362        #print "printing the elements of packet",temp,"!!!!!!!!!!!\n" 
    6463        ##################################################### 
    6564        if mode == "sync": 
    66                 (sync_signal,) = struct.unpack('!s', payload[2])  
    67                 (sync_signal_red,) = struct.unpack('!s', payload[3])  #redundant sync bit 
    68                 (data_channel,) = struct.unpack('!s', payload[4]) 
    69                 (data_channel_red,) = struct.unpack('!s', payload[5])  #redundant channel bit 
    70                 #print "printing the elements of packet  ",sync_signal,"  !!!!!!!!!!!  ",sync_signal_red," !!!!!\n"     
    71                 #print "printing the channel  ",data_channel_red,"  !!!!!!!!!!!  ",data_channel_red," !!!!!\n" 
    72                 if ok: #== True :# and str(sync_signal) == 'o' and str(sync_signal_red) == 'o': 
    73                         #print "inside if" 
    74                         if ok: #== True: #str(data_channel) == str(data_channel_red): 
    75                                 #print "inside if1$$$$$" 
    76                                 if str(data_channel) == str(ch): 
    77                                         #print "inside if2" 
    78                                         sync_status = True 
    79                                         #tb.stop() 
    80                                         #print "after tb stop ans sync status is ",sync_status," sync status\n" 
    81                                         #print "received a sync packet on channel %s\n" %(data_channel) 
    82                                         #data = 'o'+'o'+str(data_channel)+str(data_channel) 
    83                                         #print "sending this data",data,"@@@@@\n" 
    84                                         #sync_pktno=0 
    85                                         #ack_payload = struct.pack('!H', sync_pktno & 0xffff) + data 
    86                                         #print "printing the ack packet",ack_payload,"$$$$$\n" 
    87                                         #k=0 
    88                                         #while k < 10000: 
    89                                         #print "inside while" 
    90                                         #send_pkt(tb,ack_payload) #sending back the acknowledgement 
    91                                         #k=k+1 
     65                if ok: 
     66                        (pktno,) = struct.unpack('!H', payload[0:2]) 
     67                        (sync_signal,) = struct.unpack('!s', payload[2])  
     68                        (sync_signal_red,) = struct.unpack('!s', payload[3])  #redundant sync bit 
     69                        (data_channel,) = struct.unpack('!s', payload[4]) 
     70                        (data_channel_red,) = struct.unpack('!s', payload[5])  #redundant channel bit 
     71                        #print "printing the elements of packet  ",sync_signal,"  !!!!!!!!!!!  ",sync_signal_red," !!!!!\n"     
     72                        #print "printing the channel  ",data_channel_red,"  !!!!!!!!!!!  ",data_channel_red," !!!!!\n" 
     73                        #== True :# and str(sync_signal) == 'o' and str(sync_signal_red) == 'o': 
     74                        if str(data_channel) == str(ch): 
     75                                #print "inside if2" 
     76                                sync_status = True 
     77                                #tb.stop() 
     78                                #print "after tb stop ans sync status is ",sync_status," sync status\n" 
     79                                #print "received a sync packet on channel %s\n" %(data_channel) 
     80                                #data = 'o'+'o'+str(data_channel)+str(data_channel) 
     81                                #print "sending this data",data,"@@@@@\n" 
     82                                #sync_pktno=0 
     83                                #ack_payload = struct.pack('!H', sync_pktno & 0xffff) + data 
     84                                #print "printing the ack packet",ack_payload,"$$$$$\n" 
     85                                #k=0 
     86                                #while k < 10000: 
     87                                #print "inside while" 
     88                                #send_pkt(tb,ack_payload) #sending back the acknowledgement 
     89                                #k=k+1 
    9290        ##################################################### 
    9391         
    9492        ######################### traffic ############################ 
    9593        if mode == "traffic": 
    96                 (data_header,) = struct.unpack('!s', payload[0]) 
    97                 if ok and data_header == 'd': 
    98                         comm = struct.unpack('!14s', data) 
    99                         print("received this ", comm)  
     94                print "Mode is ",mode,"received traffic packet\n" 
     95                if ok: 
     96                        (data_header,) = struct.unpack('!s', payload[0]) 
     97                        if data_header == 'd': 
     98                                (comm,) = struct.unpack('!14s', payload[1:15]) 
     99                                print "received this ", comm,"\n" 
     100                else : 
     101                        print"not ok" 
    100102         
    101103        ############################################################## 
     
    236238    #resend_count= 0 #initializing resend count 
    237239    sync_pktno = 0 
    238     ch = int(random.choice('17')) 
     240    #ch = int(random.choice('17')) 
    239241    while running: 
    240242        ################################################sync mode#################################### 
     
    245247                pkt_size = 6 
    246248                data_pktno = 0  
    247                 print "printing packet size",pkt_size,"pkt size\n" 
     249                #print "printing packet size",pkt_size,"pkt size\n" 
    248250                while sync_status != True: 
    249251                        #ch = random.randint(1, 7) 
    250                         ch = int(random.choice('17')) 
     252                        ch = int(random.choice('37')) 
    251253                         
    252254                        #ch = random.randint(6,12) 
    253255                        #ch = 1 
    254256                        hop_freq = float(1e6 * (462.5625+(ch-1)*0.025))#setting the centre freq frequency for sending packets 
     257                        print "hop freq is ",hop_freq 
    255258                        tb.rxpath.min_freq = hop_freq - 80e3  
    256259                        tb.rxpath.max_freq = hop_freq + 80e3  
    257260                        is_present = tb.rxpath.get_spec_stats(1e13,1) #check if primary user is present 
    258261                        if is_present == True: #if primary user is there then dont transmit on this channel 
     262                                print "Cant use this channel..Primary user detected\n" 
    259263                                continue  
    260264                                         
     
    262266                        #print "primary user present = ",is_present,"\n" 
    263267                        #tb.rxpath.get_spec_stats(10)   
    264                         print "hop freq is ",hop_freq 
     268                         
    265269                         
    266270                        #hop_freq = float(1e6 * (462.5625+(5-1)*0.05))#setting the centre freq frequency for sending packets 
     
    277281                        print >> myfile, "out" 
    278282                        while n < nbytes: 
    279                                 print >> myfile, "inside while" 
     283                                #print >> myfile, "inside while" 
    280284                                if options_tx.from_file is None: 
    281285                                        #data = (pkt_size - 2) * chr(sync_pktno & 0xff) #0xff is 255 
     
    318322                pkt_size = 15 
    319323                sync_pktno = 0 
     324                n = 0 
    320325                while n < nbytes: 
    321326                        #print >> myfile, "inside while" 
     
    335340                                 
    336341                        send_pkt(tb,payload) 
     342                        time.sleep(0.5) 
    337343                        #print "printing payload",payload,"**\n" 
    338344                        n += len(payload) 
     
    342348                        data_pktno += 1 
    343349                        #print "before sleeping for 10 seconds and value of resend count is",resend_count 
    344                         #time.sleep(0.1) 
     350                         
    345351                        tb.rxpath.min_freq = hop_freq - 80e3  
    346352                        tb.rxpath.max_freq = hop_freq + 80e3  
    347                         is_present = tb.rxpath.get_spec_stats(1e13,10) #check if primary user is present 
     353                        is_present = tb.rxpath.get_spec_stats(1e13,1) #check if primary user is present 
    348354                        if is_present == True: #if primary user is present then get out of this communication channel, back to sync mode. 
    349355                                mode = "sync" 
    350                                  
     356                                sync_status = False 
     357                                print "Moving out of this channel..Primary user detected\n" 
    351358        ################################################ end of Communications mode####################################          
    352359