250 | | sync_status = False |
251 | | break |
252 | | ################################################end of sync mode#################################### |
253 | | |
| 251 | traffic_flag = False |
| 252 | sync_status="False" |
| 253 | |
| 254 | ################################################end of sync mode#################################### |
| 255 | |
| 256 | ################################################Communications mode################################# |
| 257 | if mode == "traffic": |
| 258 | print "Inside traffic mode" |
| 259 | if check_sync == 0: |
| 260 | time.sleep(0.8) |
| 261 | if traffic_flag != True: |
| 262 | mode = "sync" |
| 263 | continue |
| 264 | else: |
| 265 | check_sync = 1 |
| 266 | |
| 267 | nbytes = 15 |
| 268 | pkt_size = 15 |
| 269 | data_pktno = 0 |
| 270 | n = 0 |
| 271 | while n < nbytes: |
| 272 | #print >> myfile, "inside while" |
| 273 | if options_tx.from_file is None: |
| 274 | #data = (pkt_size - 2) * chr(data_pktno & 0xff) #0xff is 255 |
| 275 | data = 'dHi how are you' #Sending this message |
| 276 | #print >> myfile, data |
| 277 | #print "printing data",data,"****\n" |
| 278 | else: |
| 279 | data = source_file.read(pkt_size - 2) |
| 280 | if data == '': |
| 281 | break; |
| 282 | |
| 283 | |
| 284 | payload = struct.pack('!15s', data) |
| 285 | #print "printing payload",payload,"**\n" |
| 286 | |
| 287 | send_pkt(tb,payload) |
| 288 | #print "printing payload",payload,"**\n" |
| 289 | n += len(payload) |
| 290 | sys.stderr.write('.') |
| 291 | if options_tx.discontinuous and data_pktno % 5 == 4: |
| 292 | time.sleep(1) |
| 293 | data_pktno += 1 |
| 294 | #print "before sleeping for 10 seconds and value of resend count is",resend_count |
| 295 | time.sleep(0.2) |
| 296 | ch_energy = tb.rxpath.probe.level() #check if primary user is present |
| 297 | print "channel energy is ",ch_energy,"\n" |
| 298 | if int(ch_energy) > 2e7: #if primary user is there then dont transmit on this channel |
| 299 | mode = "sync" |
| 300 | |