summaryrefslogtreecommitdiff
path: root/cesar/maximus/python/py/test_tx_rx.py
diff options
context:
space:
mode:
authorsave2008-04-07 14:17:42 +0000
committersave2008-04-07 14:17:42 +0000
commit3d58a62727346b7ac1a6cb36fed1a06ed72228dd (patch)
treed7788c3cf9f76426aef0286d0202e2097f0fa0eb /cesar/maximus/python/py/test_tx_rx.py
parent095dca4b0a8d4924093bab424f71f588fdd84613 (diff)
Moved the complete svn base into the cesar directory.
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1769 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/maximus/python/py/test_tx_rx.py')
-rw-r--r--cesar/maximus/python/py/test_tx_rx.py217
1 files changed, 217 insertions, 0 deletions
diff --git a/cesar/maximus/python/py/test_tx_rx.py b/cesar/maximus/python/py/test_tx_rx.py
new file mode 100644
index 0000000000..ac1867ec2b
--- /dev/null
+++ b/cesar/maximus/python/py/test_tx_rx.py
@@ -0,0 +1,217 @@
+#!/usr/bin/python
+
+print "\n*** " + __file__ + " ***\n"
+
+import sys
+sys.path.append('./test')
+sys.path.append('../test')
+import startup
+
+from interface import *
+from maximus import *
+from struct import pack
+
+m = Maximus()
+m.init(sys.argv)
+
+
+# TEST TX AND RX
+# To be run with "test_tx_rx.elf" station executable
+# (to be compiled under "/trunk/maximus/stationtest").
+
+# Create station(s)
+sta1 = m.create_sta ()
+
+# Enable channel perturbation
+m.disturb_channel()
+
+# Set tonemask
+fcall1 = m.create_fcall('set_tonemask')
+fcall1.send(sta1)
+
+def create_fcall_128():
+ # Create a fcall for an MPDU containing one PB of 128 octets
+ fc_mode = 2 # PHY_FC_MODE_AV_1
+ short_ppdu = False
+ mod = 2 # PHY_MOD_MINI_ROBO
+ fecrate = 0 # PHY_FEC_RATE_1_2
+ pb_size = 0 # PHY_PB_SIZE_136
+ gil = 1 # PHY_GIL_567
+ pb_nb = 1
+ fcall_128 = m.create_fcall('prepare_rx')
+ fcall_128.add_param_ushort("fc_mode", fc_mode)
+ fcall_128.add_param_bool("short_ppdu", short_ppdu)
+ fcall_128.add_param_ushort("mod", mod)
+ fcall_128.add_param_ushort("fecrate", fecrate)
+ fcall_128.add_param_ushort("pb_size", pb_size)
+ fcall_128.add_param_ushort("gil", gil)
+ fcall_128.add_param_ushort("pb_nb", pb_nb)
+ return fcall_128
+
+def create_fcall_512_1():
+ # Create a fcall for an MPDU containing one PB of 512 octets with a FC 1.0
+ fc_mode = 0 # PHY_FC_MODE_HYBRID_1
+ short_ppdu = False
+ mod = 3 # PHY_MOD_TM
+ fecrate = 0 # PHY_FEC_RATE_1_2
+ pb_size = 1 # PHY_PB_SIZE_520
+ gil = 1 # PHY_GIL_567
+ pb_nb = 1
+ fcall_512_1 = m.create_fcall('prepare_rx')
+ fcall_512_1.add_param_ushort("fc_mode", fc_mode)
+ fcall_512_1.add_param_bool("short_ppdu", short_ppdu)
+ fcall_512_1.add_param_ushort("mod", mod)
+ fcall_512_1.add_param_ushort("fecrate", fecrate)
+ fcall_512_1.add_param_ushort("pb_size", pb_size)
+ fcall_512_1.add_param_ushort("gil", gil)
+ fcall_512_1.add_param_ushort("pb_nb", pb_nb)
+ return fcall_512_1
+
+def create_fcall_512_3():
+ # Create a fcall for an MPDU containing 3 PBs of 512 octets
+ fc_mode = 2 # PHY_FC_MODE_AV_1
+ short_ppdu = False
+ mod = 0 # PHY_MOD_ROBO
+ fecrate = 0 # PHY_FEC_RATE_1_2
+ pb_size = 1 # PHY_PB_SIZE_520
+ gil = 0 # PHY_GIL_417
+ pb_nb = 3
+ fcall_512_3 = m.create_fcall('prepare_rx')
+ fcall_512_3.add_param_ushort("fc_mode", fc_mode)
+ fcall_512_3.add_param_bool("short_ppdu", short_ppdu)
+ fcall_512_3.add_param_ushort("mod", mod)
+ fcall_512_3.add_param_ushort("fecrate", fecrate)
+ fcall_512_3.add_param_ushort("pb_size", pb_size)
+ fcall_512_3.add_param_ushort("gil", gil)
+ fcall_512_3.add_param_ushort("pb_nb", pb_nb)
+ return fcall_512_3
+
+def create_fcall_short_fc10():
+ # Create a fcall for a short PPDU with a FC 1.0
+ fc_mode = 0 # PHY_FC_MODE_HYBRID_1
+ short_ppdu = True
+ fcall_short_fc10 = m.create_fcall('prepare_rx')
+ fcall_short_fc10.add_param_ushort("fc_mode", fc_mode)
+ fcall_short_fc10.add_param_bool("short_ppdu", short_ppdu)
+ fcall_short_fc10.add_param_ushort("mod", 0)
+ fcall_short_fc10.add_param_ushort("fecrate", 0)
+ fcall_short_fc10.add_param_ushort("pb_size", 0)
+ fcall_short_fc10.add_param_ushort("gil", 0)
+ fcall_short_fc10.add_param_ushort("pb_nb", 0)
+ return fcall_short_fc10
+
+def get_pad(n):
+ pad = ''
+ for i in range (0,n):
+ pad += pack('B', 0)
+ return pad
+
+# Test following functions:
+# - send(self, maximus, fc_mode=4, short_ppdu=0, mod=4, file=None)
+# - sendnrecv(self, maximus, fc_mode=4, short_ppdu=0, mod=4, file=None, timeout=None, filter=None, count=1)
+# - recv(maximus, timeout=None, filter=None, count=1)
+
+# Send an MPDU containing one PB of 128 octets
+fcall_128 = create_fcall_128()
+fcall_128.send(sta1)
+macFrame1 = MACFrame()
+fc_av_1 = (0, 456, 789, 10)
+macFrame1.set_fc_av(fc_av_1)
+msdu1 = 'This is the MPDU payload'
+macFrame1.set_msdu(msdu1)
+macFrame1.set_macframeheader(MACFrameHeader(MFL=len(msdu1)-1))
+macFrame1.send(m)
+rsp1 = recv(m)
+if rsp1[0].get_fc_av() != fc_av_1:
+ print "fc_av_1 =", rsp1[0].get_fc_av()
+ raise Error("fc_av_1")
+if rsp1[0].get_pblist()[0] != MACFrameHeader(MFL=len(msdu1)-1).get() + msdu1 + macFrame1.get_icv() + get_pad(98):
+ print "msdu1 =", rsp1[0].get_pblist()[0]
+ raise Error("msdu1")
+m.wait(100000)
+
+# Send an MPDU containing 3 PBs of 512 octets
+fcall_512_3 = create_fcall_512_3()
+fcall_512_3.send(sta1)
+macFrame2 = MACFrame()
+fc_av_2 = fc_av_1
+macFrame2.set_fc_av(fc_av_2)
+msdu2 = 1500*'a'
+macFrame2.set_msdu(msdu2)
+macFrame2.set_macframeheader(MACFrameHeader(MFL=len(msdu2)-1))
+rsp2 = macFrame2.sendnrecv(m)
+if rsp2[0].get_fc_av() != fc_av_2:
+ print "fc_av_2 =", rsp2[0].get_fc_av()
+ raise Error("fc_av_2")
+if rsp2[0].get_pblist()[0] != MACFrameHeader(MFL=len(msdu2)-1).get() + 510*'a' \
+or rsp2[0].get_pblist()[1] != 512*'a' \
+or rsp2[0].get_pblist()[2] != 478*'a' + macFrame2.get_icv() + get_pad(30):
+ print "msdu2 =", rsp2[0].get_pblist()[0], rsp2[0].get_pblist()[1], rsp2[0].get_pblist()[2]
+ raise Error("msdu2")
+m.wait(100000)
+
+# Send a short PPDU with a FC 1.0
+fcall_short_fc10 = create_fcall_short_fc10()
+fcall_short_fc10.send(sta1)
+macFrame3 = MACFrame()
+fc_10_3 = 1
+macFrame3.set_fc_10(fc_10_3)
+fc_av_3 = (123, 456, 789, 10)
+macFrame3.set_fc_av(fc_av_3)
+macFrame3.send(maximus=m, short_ppdu=True)
+# no rsp3
+m.wait(100000)
+
+# Send an MPDU containing one PB of 512 octets with a FC 1.0
+fcall_512_1 = create_fcall_512_1()
+fcall_512_1.send(sta1)
+macFrame4 = MACFrame()
+fc_10_4 = 10
+macFrame4.set_fc_10(fc_10_4)
+fc_av_4 = fc_av_1
+macFrame4.set_fc_av(fc_av_4)
+msdu4 = 200*'b'
+macFrame4.set_msdu(msdu4)
+macFrame4.set_macframeheader(MACFrameHeader(MFL=len(msdu4)-1))
+macFrame4.send(m)
+rsp4 = recv(m)
+if rsp4[0].get_fc_10() != fc_10_4:
+ print "fc_10_4 =", rsp4[0].get_fc_10()
+ raise Error("fc_10_4")
+if rsp4[0].get_fc_av() != fc_av_4:
+ print "fc_av_4 =", rsp4[0].get_fc_av()
+ raise Error("fc_av_4")
+if rsp4[0].get_pblist()[0] != MACFrameHeader(MFL=len(msdu4)-1).get() + msdu4 + macFrame4.get_icv() + get_pad(306):
+ print "msdu4 =", rsp4[0].get_pblist()[0]
+ raise Error("msdu4")
+m.wait(100000)
+
+# Send an MPDU containing one PB of 128 octets, created from an MME
+fcall_128 = create_fcall_128()
+fcall_128.send(sta1)
+icv5 = 'ICV!'
+macFrame5 = MACFrame(ICV=icv5)
+fc_av_5 = fc_av_1
+macFrame5.set_fc_av(fc_av_5)
+mmheader5 = 'MMHeader 19 octets!'
+mmentry5 = '--- This is the Management Message Entry ---'
+msdu5 = MME(MMHeader=mmheader5, MMEntry=mmentry5)
+macFrame5.set_msdu(msdu5)
+macFrame5.set_macframeheader(MACFrameHeader(MFL=len(mmheader5)+len(mmentry5)-1))
+rsp5 = macFrame5.sendnrecv(m)
+if rsp5[0].get_fc_av() != fc_av_5:
+ print "fc_av_5 =", rsp5[0].get_fc_av()
+ raise Error("fc_av_5")
+if rsp5[0].get_pblist()[0] != MACFrameHeader(MFL=len(mmheader5)+len(mmentry5)-1).get() + mmheader5 + mmentry5 + macFrame5.get_icv() + get_pad(59):
+ print "msdu5 =", rsp5[0].get_pblist()[0]
+ raise Error("msdu5")
+m.wait(100000)
+
+# Uninitialize PHY
+fcall2 = m.create_fcall('uninit_phy')
+fcall2.send(sta1)
+
+# Remove station(s)
+sta1.remove()
+
+print "\n*** END ***\n"