Index: vtcross/branches/sriram/benchmark_txrxnode1.py
===================================================================
--- vtcross/branches/sriram/benchmark_txrxnode1.py	(revision 356)
+++ vtcross/branches/sriram/benchmark_txrxnode1.py	(revision 358)
@@ -62,6 +62,6 @@
         #temp = struct.unpack('!s', payload[3:10])
 	#print "printing the elements of packet",temp,"!!!!!!!!!!!\n"
-        if mode == "sync":
-	#####################################################
+        #####################################################
+	if mode == "sync":
 		(sync_signal,) = struct.unpack('!s', payload[2]) 
         	(sync_signal_red,) = struct.unpack('!s', payload[3])  #redundant sync bit
@@ -92,4 +92,14 @@
 	#####################################################
 	
+	######################### traffic ############################
+	if mode == "traffic":
+		if ok == True:
+			comm = struct.unpack('!14s', data)
+			print("received this ", comm) 
+	
+	##############################################################
+	
+
+
         n_rcvd += 1
         if ok:
@@ -227,4 +237,5 @@
     ch = int(random.choice('17'))
     while running:
+  	################################################sync mode####################################
     	if mode == "sync":
     		#nbytes = int(1e6 * .0003)
@@ -298,5 +309,7 @@
 	    	#myfile.close()
 	    	#tb.wait()
-
+	################################################end of sync mode####################################
+
+	################################################Communications mode####################################
     	if mode == "traffic":
 		nbytes = 16
@@ -315,5 +328,6 @@
                 	        	break;
 	
-                	payload = struct.pack('!H', data_pktno & 0xffff) + data
+			
+                	payload = struct.pack('!14s', data)
 	       		#print "printing payload",payload,"**\n"
 				
@@ -333,5 +347,5 @@
 				mode = "sync"
 				
-				
+	################################################ end of Communications mode####################################		
 
 
Index: vtcross/branches/sriram/benchmark_txrxnode2.py
===================================================================
--- vtcross/branches/sriram/benchmark_txrxnode2.py	(revision 320)
+++ vtcross/branches/sriram/benchmark_txrxnode2.py	(revision 358)
@@ -12,5 +12,5 @@
 from transmit_path import transmit_path
 from receive_path import receive_path
-global sync_status
+global sync_status,mode
 sync_status=False
 
@@ -28,9 +28,9 @@
 #//////main////// 
 
-global n_rcvd, n_right,ch
+global n_rcvd, n_right,ch,traffic_flag
 
 def main():
-    global n_rcvd, n_right,sync_status,pktno1,ch
-    pktno1 =0
+    global n_rcvd, n_right,sync_status,sync_pktno,ch,mode,traffic_flag
+    sync_pktno =0
     n_rcvd = 0
     n_right = 0
@@ -39,41 +39,51 @@
 
     def rx_callback(ok, payload):
-        global n_rcvd, n_right,sync_status,pktno1,ch
+        global n_rcvd, n_right,sync_status,sync_pktno,ch,mode,traffic_flag
         #(pktno,) = struct.unpack('!H', payload[0:2])
         print "inside rx callback"
-        if ok == True:
-	    (sync_signal,) = struct.unpack('!s', payload[2])  
-            (sync_signal_red,) = struct.unpack('!s', payload[3])  #redundant sync bit
-            (data_channel,) = struct.unpack('!s', payload[4])
-            (data_channel_red,) = struct.unpack('!s', payload[5])  #redundant channel bit
-	    print "printing the elements of packet  ",str(sync_signal),"  !!!!!!!!!!!  ",str(sync_signal_red)," !!!!!\n"     
-            print "printing the channel  ",str(data_channel_red),"  !!!!!!!!!!!  ",str(data_channel_red)," !!!!!\n"
-	    #if str(sync_signal) == 's' and str(sync_signal_red) == 's' and str(data_channel) == str(data_channel_red):
-	    if str(data_channel) == str(ch):
-            	#print "inside if"
-            	sync_status = True
-		#tb.stop()
-                #print "received a sync packet on channel %s\n" %(data_channel)
-	        data = str('o'+'o'+str(data_channel)+str(data_channel))
-                #print "sending this data",data,"@@@@@\n"
-		#pktno1=0
-	        ack_payload = struct.pack('!H', pktno1 & 0xffff) + data
-		pktno1+=1
-		#print "printing ack packet and sent pkt no ",ack_payload," ",pktno1,"\n"
-		#print "printing the 3rd byte ",struct.unpack('!s', ack_payload[2]) ," \n"
-                #k=0
-                #while k < 10000:
-		#print "inside while"
-	        send_pkt(tb,ack_payload) #sending back the acknowledgement
-		#send_pkt(tb,ack_payload) #sending back the acknowledgement
-		#send_pkt(tb,ack_payload) #sending back the acknowledgement
-		#send_pkt(tb,ack_payload) #sending back the acknowledgement
-		#send_pkt(tb,ack_payload) #sending back the acknowledgement
-		#send_pkt(tb,ack_payload) #sending back the acknowledgement
-		#send_pkt(tb,ack_payload) #sending back the acknowledgement
-		
-                #k=k+1
+	########################## sync ###########################
+	if mode == "sync":
+        	if ok == True:
+	    		(sync_signal,) = struct.unpack('!s', payload[2])  
+            		(sync_signal_red,) = struct.unpack('!s', payload[3])  #redundant sync bit
+            		(data_channel,) = struct.unpack('!s', payload[4])
+            		(data_channel_red,) = struct.unpack('!s', payload[5])  #redundant channel bit
+	    		print "printing the elements of packet  ",str(sync_signal),"  !!!!!!!!!!!  ",str(sync_signal_red)," !!!!!\n"     
+            		print "printing the channel  ",str(data_channel_red),"  !!!!!!!!!!!  ",str(data_channel_red)," !!!!!\n"
+	    		#if str(sync_signal) == 's' and str(sync_signal_red) == 's' and str(data_channel) == str(data_channel_red):
+	    		if str(data_channel) == str(ch):
+            			#print "inside if"
+            			sync_status = True
+				#tb.stop()
+                		#print "received a sync packet on channel %s\n" %(data_channel)
+	        		data = str('o'+'o'+str(data_channel)+str(data_channel))
+                		#print "sending this data",data,"@@@@@\n"
+				#sync_pktno=0
+	        		ack_payload = struct.pack('!H', sync_pktno & 0xffff) + data
+				sync_pktno+=1
+				#print "printing ack packet and sent pkt no ",ack_payload," ",sync_pktno,"\n"
+				#print "printing the 3rd byte ",struct.unpack('!s', ack_payload[2]) ," \n"
+                		#k=0
+                		#while k < 10000:
+				#print "inside while"
+	        		send_pkt(tb,ack_payload) #sending back the acknowledgement
+		                #k=k+1
+				print "ok = %5s  sync_pktno = %4d  n_rcvd = %4d  n_right = %4d" % (
+        			    ok, sync_pktno, n_rcvd, n_right)
  		    
-        n_rcvd += 1
+        #####################################################
+	
+	######################### traffic ############################
+	if mode == "traffic":
+		if ok == True:
+			traffic_flag = True
+			comm = struct.unpack('!14s', data)
+			print("received this ", comm) 
+	
+	##############################################################
+
+
+
+	n_rcvd += 1
         if ok:
             n_right += 1
@@ -178,30 +188,79 @@
     tb.start()
     #listening to random frequencies untill a match is found
-    check = True
+    running = True
     global ch
-    while check:
-    	if sync_status != True:
-        	#print "inside while"
-        	#ch = random.randint(1, 7)
-		ch = int(random.choice('17'))
-		#ch = random.randint(6, 12)
-		#ch = 1
-        	#hop_freq = float(1e6 * (400+(ch-1)*10))#setting the centre freq frequency for sending packets
-		hop_freq = float(1e6 * (462.5625+(ch-1)*0.025))
-		#hop_freq = float(1e6 * (462.5625+(5-1)*0.05))
-        	print "hop freq is",hop_freq,"@@@@\n"
-        	tb.txpath.set_freq(hop_freq)
-        	tb.rxpath.set_freq(hop_freq)
-		time.sleep(0.05)
-		#time.sleep(2)
-	else:
-		print "inside lese of while check"
-		#tb.stop()
-		break
-    temp_variable = 2
-    if temp_variable == 2:
-        print "success"
+    while running:
+	################################################sync mode####################################
+    	if mode == "sync":
+    		if sync_status != True:
+        		#print "inside while"
+        		#ch = random.randint(1, 7)
+			ch = int(random.choice('17'))
+			#ch = random.randint(6, 12)
+			#ch = 1
+        		#hop_freq = float(1e6 * (400+(ch-1)*10))#setting the centre freq frequency for sending packets
+			hop_freq = float(1e6 * (462.5625+(ch-1)*0.025))
+			#hop_freq = float(1e6 * (462.5625+(5-1)*0.05))
+        		print "hop freq is",hop_freq,"@@@@\n"
+        		tb.txpath.set_freq(hop_freq)
+        		tb.rxpath.set_freq(hop_freq)
+			time.sleep(0.05)
+			#time.sleep(2)
+		else:
+			print "inside lese of while check"
+			#tb.stop()
+			break
+    		temp_variable = 2
+    		if temp_variable == 2:
+        		print "success"
     
-    print "sync channel is found! and it is channel ",ch," \n"  
+    		print "sync channel is found! and it is channel ",ch," \n"  
+		mode = "traffic"
+	
+	################################################end of sync mode####################################
+
+	################################################Communications mode####################################	
+	if mode == "traffic":
+		time.sleep(0.4)
+		if traffic_flag != True
+			mode = "sync"
+		nbytes = 14
+    	    	pkt_size = 14
+		sync_pktno = 0
+		while n < nbytes:
+                	#print >> myfile, "inside while"
+               		if options_tx.from_file is None:
+                 		#data = (pkt_size - 2) * chr(data_pktno & 0xff) #0xff is 255
+                		data = 'I am fine.....' #Sending this message
+	        		#print >> myfile, data
+                		#print "printing data",data,"****\n"
+                	else:
+            		    	data = source_file.read(pkt_size - 2)
+            		    	if data == '':
+                	        	break;
+	
+			
+                	payload = struct.pack('!14s', data)
+	       		#print "printing payload",payload,"**\n"
+				
+                	send_pkt(tb,payload)
+			#print "printing payload",payload,"**\n"
+                	n += len(payload)
+                	sys.stderr.write('.')
+                	if options_tx.discontinuous and data_pktno % 5 == 4:
+                		time.sleep(1)
+                	data_pktno += 1
+	    		#print "before sleeping for 10 seconds and value of resend count is",resend_count
+			#time.sleep(0.1)
+			tb.rxpath.min_freq = hop_freq - 80e3 
+    		    	tb.rxpath.max_freq = hop_freq + 80e3 
+			is_present = tb.rxpath.get_spec_stats(1e13,10) #check if primary user is present
+			if is_present == True: #if primary user is present then get out of this communication channel, back to sync mode.
+				mode = "sync"
+	
+	################################################ end of Communications mode####################################		
+
+
+
     #var2  = 2
     #if var2 ==2:
@@ -215,5 +274,5 @@
 
     #tb.wait()
-    tb.stop()
+    #tb.stop()
 
 if __name__ == '__main__':
