0% found this document useful (0 votes)
268 views42 pages

GNU Radio - benchmarkTX Code Walk Through

The document provides a walkthrough of the benchmark_tx.py code, which is used to transmit data in GNU Radio. It imports necessary modules, constructs a transmitter flowgraph, allows the user to set transmission options, generates packets from raw data or a file, and sends the packets through the flowgraph. The main function constructs the flowgraph, starts the transmission, and keeps the flowgraph running until the user interrupts it to stop execution.

Uploaded by

Hilmi Mujahid
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
268 views42 pages

GNU Radio - benchmarkTX Code Walk Through

The document provides a walkthrough of the benchmark_tx.py code, which is used to transmit data in GNU Radio. It imports necessary modules, constructs a transmitter flowgraph, allows the user to set transmission options, generates packets from raw data or a file, and sends the packets through the flowgraph. The main function constructs the flowgraph, starts the transmission, and keeps the flowgraph running until the user interrupts it to stop execution.

Uploaded by

Hilmi Mujahid
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

GNURadio

CodeWalkthroughforbenchmark_tx.py Mohd Adib Sarijari TelematicsResearchGroup,UTM

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pyoverview
Codeexampletotransmitdata. Includerawdataandfiletransmission(canbe selected). PHYLayerpacketisalreadyported.User implementationisstartingfromMAClayer andabove.

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycode

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough
Makesthepythoncode executablebyexecuting $chmod+x filename.py"

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough

GNUPublicLicence(incomment)

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough
ImportingNecessaryModules, modulesfromGNUlibrary

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough

ImportingNecessaryModules, modulesfromPython

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough

ImportingNecessaryModules, modulesfromCurrentDirectory

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough
Topblockclassforconstructingthe transmitterflowgraph

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough

MainFunction

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough

Sendpacketfunction(local functioninsidemain)

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough

Receivedpacketfunction(local functioninsidemain) NOT IMPLEMENTEDinthedefault transmittercode.

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough
Modulationinitialization(pointer passingformodulationdata buffer)

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough
Inputsettingfromuserfor transmitter. Settingbyuserisperformed duringpythonfileexecution. ThisisusingOptionParser class (classprovidedbypython /usr/lib/python2.5/optpasrse.py).

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough
Includetheoptionselectedby userfortransmitterinthe transmit_path file.

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough

Passoptionsselectedtoall modulatorfile(dqpsk,d8psk, cpm,qam8,dbpsk andgmsk)

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough

Parsethecommandline optionfoundinargs. Checkforerrorintheparsing process. Returntwovalue: o Value>option(passing alltheoptionvalue) o args >args (reporton anyerror)

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough

Reportingerrorifany. Exittheprogramiserror occur.

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough

Checkingontheavailability oftransmissionfrequency chose. Reporterrorifnofrequency selectedandexitthe program.

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough

Openthefilewhichuser wanttotransmit(iffile transmissionoptionis chooseduringthe executionsetup)


http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough
Constructingthetransmit flowgraph andpassthepointer toavariablecalledtb.

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough

Receiveparameterfromthecalled command: mods[options.modulation] >modulator options>options

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough

Passtheoptiontotransmitter (transmit_path file). Transmitterissettingupusing theselectedsetting. Passedthetransmitterpointer toself.txpath.

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough

Connectandconstructthe flowgraph usingconnectclass.

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough
Enabletherealtime schedulingforflowgraph tobe abletorun.

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough
Checkingerrorinthestatusof realtimeschedulingenabling.

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough
Starttheexecutionofthe constructedflowgraph usingstartmethod. Flowgraph propertiesin includestart,stopandwait.

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough

Variableinitializationfor packettransmission

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough

Totalbytetobesend

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough

Sizeforeachpacket

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough

Generatepacket(ifrawdata transmissionischosen)

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough

Genarate packet(ifdatafrom fileischosen)

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough

Constructpacketusing struct.pack method(python class) Thisistoenablepacketto bepassedfromfunctionto functioneasily.


http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough

sendpackettroughsend_pkt function.

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough

Payloadispassedtothe variablenamedpayload. eof istotellthesendfunction whichpacketisthelastpacket tobetransmitted.

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough

Ifdiscontinuesisselectedthen after4bytesend,thenpause1 second.

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough
Tellsendfunctionthatwehave finishedsendingpacket.

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough
Thisistomakethe flowgraph keeprunning untiluserasktostop. Notethatmainisonlyone thread,theremightbe anotherthreadrunningin theprogram.

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough
Thisiswherepythoncode willgoatthefirsttime duringtheexecution(after theimportandinclude work). ItislikeamainfunctioninC programming.

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough
Mainiscalledbythis command.

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

benchmark_tx.pycodewalkthrough

Commandtocaptureuser interruptcommand(cntrl+c)to stopthecodeexecution properly.

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

Q&A
ThankYouforYourAttention

http://trg.fke.utm.my/ InspiringCreative&InnovativeMinds

You might also like