Index: vtcross/branches/sriram/benchmark_txrxnode2.py
===================================================================
--- vtcross/branches/sriram/benchmark_txrxnode2.py	(revision 361)
+++ vtcross/branches/sriram/benchmark_txrxnode2.py	(revision 364)
@@ -29,4 +29,5 @@
 
 global n_rcvd, n_right,ch,traffic_flag
+traffic_flag = False
 
 def main():
@@ -76,9 +77,18 @@
 	######################### traffic ############################
 	if mode == "traffic":
-		(data_header,) = struct.unpack('!s', payload[0])
-		if ok and data_header == 'd':
-			traffic_flag = True
-			comm = struct.unpack('!14s', data)
-			print("received this ", comm) 
+		
+		if ok:
+			print "received a packet"
+			(data_header,) = struct.unpack('!s', payload[0])
+			if data_header == 'd':
+				traffic_flag = True
+				(comm,) = struct.unpack('!14s', payload[1:15])
+				print "received this ", comm,"\n"
+				data = 'dI am fine.....' #Sending this message
+				payload = struct.pack('!15s', data)
+				send_pkt(tb,payload)
+		
+		else:
+			print "not ok"
 	
 	##############################################################
@@ -212,11 +222,18 @@
         		#print "inside while"
         		#ch = random.randint(1, 7)
-			ch = int(random.choice('17'))
+			ch = int(random.choice('37'))
 			#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))
+			tb.rxpath.min_freq = hop_freq - 80e3 
+    		    	tb.rxpath.max_freq = hop_freq + 80e3 
+			is_present = tb.rxpath.get_spec_stats(1e13,1) #check if primary user is present
+			print "hop freq is",hop_freq,"@@@@\n"
+			if is_present == True: #if primary user is there then dont transmit on this channel
+				print "Cant use this channel..Primary user detected\n"
+				continue
 			#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)
@@ -225,5 +242,6 @@
 		else:
 			print "inside lese of while check"
-			check_sync == 0
+			check_sync = 0
+			traffic_flag  = False
 			print "sync channel is found! and it is channel ",ch," \n"  
 			mode = "traffic"
@@ -241,45 +259,53 @@
 	if mode == "traffic":
 		print "Inside traffic mode"
+		##################### for ensuring sync #####################
 		if check_sync == 0:
 			time.sleep(0.4)
 			if traffic_flag != True:
 				mode = "sync"
+				sync_status=False
 				continue
 			else:
 				check_sync == 1	
-		nbytes = 15
-    	    	pkt_size = 15
-		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 = 'dI 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('!15s', data)
+		############################################################
+
+		#nbytes = 15
+    	    	#pkt_size = 15
+		#data_pktno = 0
+		#n = 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 = 'dI 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('!15s', data)
 	       		#print "printing payload",payload,"**\n"
 				
-                	send_pkt(tb,payload)
+                #	send_pkt(tb,payload)
+		#	time.sleep(0.5)
 			#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
+                #	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"
-	
+		
+		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"
+			sync_status=False
+			print "Moving out of this channel..Primary user detected\n"
+		time.sleep(0.5)	
 	################################################ end of Communications mode####################################		
 
