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; |
| 277 | nbytes = 15 |
| 278 | pkt_size = 15 |
| 279 | data_pktno = 0 |
| 280 | n = 0 |
| 281 | while n < nbytes: |
| 282 | #print >> myfile, "inside while" |
| 283 | if options_tx.from_file is None: |
| 284 | #data = (pkt_size - 2) * chr(data_pktno & 0xff) #0xff is 255 |
| 285 | data = 'dHi how are you' #Sending this message |
| 286 | #print >> myfile, data |
| 287 | #print "printing data",data,"****\n" |
| 288 | else: |
| 289 | data = source_file.read(pkt_size - 2) |
| 290 | if data == '': |
| 291 | break; |
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 | | |
| 297 | send_pkt(tb,payload) |
| 298 | print "printing payload",data,"**\n" |
| 299 | n += len(payload) |
| 300 | sys.stderr.write('.') |
| 301 | if options_tx.discontinuous and data_pktno % 5 == 4: |
| 302 | time.sleep(1) |
| 303 | data_pktno += 1 |
| 304 | #print "before sleeping for 10 seconds and value of resend count is",resend_count |
| 305 | time.sleep(0.2) |
| 306 | ch_energy = tb.rxpath.probe.level() #check if primary user is present |
| 307 | print "channel energy is ",ch_energy,"\n" |
| 308 | if int(ch_energy) > 2e7: #if primary user is there then dont transmit on this channel |
| 309 | mode = "sync" |
| 310 | |