summaryrefslogtreecommitdiff
path: root/cesar/maximus/python/py/test_send_mpdu.py
blob: 59136bd89228533f5c9eb33d04e583a6641806b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/usr/bin/python

import sys
sys.path.append('./test')
sys.path.append('../test')
import startup

from interface import *
from maximus import *
from maximus.macframe.macframequeue import MAX_PB_NB_PER_MPDU
from struct import pack

# To be run with "test_send.elf" station executable
# (to be compiled under "/trunk/maximus/stationtest").

maximus = Maximus()
maximus.init(sys.argv)

def send_fcall2(station):
    # Send an fcall for one PB of 128 octets
    fcall2 = maximus.create_fcall('prepare_rx')
    fc_mode = 2 # PHY_FC_MODE_AV_1
    fcall2.add_param_ushort("fc_mode", fc_mode)
    fcall2.add_param_bool("short_ppdu", False)
    mod = 2 # PHY_MOD_MINI_ROBO
    fcall2.add_param_ushort("mod", mod)
    fecrate = 0 # PHY_FEC_RATE_1_2
    fcall2.add_param_ushort("fecrate", fecrate)
    pb_size = 0 # PHY_PB_SIZE_136
    fcall2.add_param_ushort("pb_size", pb_size)
    gil = 1 # PHY_GIL_567
    fcall2.add_param_ushort("gil", gil)
    pb_nb = 1
    fcall2.add_param_ushort("pb_nb", pb_nb)
    fcall2.send(station)

def send_fcall3(station):
    # Send an fcall for 3 PBs of 512 octets
    fcall3 = maximus.create_fcall('prepare_rx')
    fc_mode = 2 # PHY_FC_MODE_AV_1
    fcall3.add_param_ushort("fc_mode", fc_mode)
    fcall3.add_param_bool("short_ppdu", False)
    mod = 0 # PHY_MOD_ROBO
    fcall3.add_param_ushort("mod", mod)
    fecrate = 0 # PHY_FEC_RATE_1_2
    fcall3.add_param_ushort("fecrate", fecrate)
    pb_size = 1 # PHY_PB_SIZE_520
    fcall3.add_param_ushort("pb_size", pb_size)
    gil = 0 # PHY_GIL_417
    fcall3.add_param_ushort("gil", gil)
    pb_nb = 3
    fcall3.add_param_ushort("pb_nb", pb_nb)
    fcall3.send(station)

def send_fcall4(station):
    # Send an fcall for a short PPDU with a FC 1.0
    fcall4 = maximus.create_fcall('prepare_rx')
    fc_mode =  0 # PHY_FC_MODE_HYBRID_1
    fcall4.add_param_ushort("fc_mode", fc_mode)
    fcall4.add_param_bool("short_ppdu", True)
    fcall4.send(station)

def send_fcall5(station):
    # Send an fcall for one PB of 512 octets with a FC 1.0
    fcall5 = maximus.create_fcall('prepare_rx')
    fc_mode = 0 # PHY_FC_MODE_HYBRID_1
    fcall5.add_param_ushort("fc_mode", fc_mode)
    fcall5.add_param_bool("short_ppdu", False)
    mod = 0 # PHY_MOD_ROBO
    fcall5.add_param_ushort("mod", mod)
    fecrate = 0 # PHY_FEC_RATE_1_2
    fcall5.add_param_ushort("fecrate", fecrate)
    pb_size = 1 # PHY_PB_SIZE_520
    fcall5.add_param_ushort("pb_size", pb_size)
    gil = 0 # PHY_GIL_417
    fcall5.add_param_ushort("gil", gil)
    pb_nb = 1
    fcall5.add_param_ushort("pb_nb", pb_nb)
    fcall5.send(station)

def send_fcall_236(station):
    # Send an fcall for 236 PBs of 512 octets
    fcall_236 = maximus.create_fcall('prepare_rx')
    fc_mode = 2 # PHY_FC_MODE_AV_1
    fcall_236.add_param_ushort("fc_mode", fc_mode)
    fcall_236.add_param_bool("short_ppdu", False)
    mod = 0 # PHY_MOD_ROBO
    fcall_236.add_param_ushort("mod", mod)
    fecrate = 0 # PHY_FEC_RATE_1_2
    fcall_236.add_param_ushort("fecrate", fecrate)
    pb_size = 1 # PHY_PB_SIZE_520
    fcall_236.add_param_ushort("pb_size", pb_size)
    gil = 0 # PHY_GIL_417
    fcall_236.add_param_ushort("gil", gil)
    pb_nb = MAX_PB_NB_PER_MPDU
    fcall_236.add_param_ushort("pb_nb", pb_nb)
    fcall_236.send(station)

sta = maximus.create_sta ()
sta.debug ()

fcall1 = maximus.create_fcall('set_tonemask')
fcall1.send(sta)

# Send an MPDU containing one PB of 128 octets
send_fcall2(sta)
macFrame2 = MACFrame()
macFrame2.set_fc_av(pack('IIII', 123, 456, 789, 10))
macFrame2.set_msdu('This is the MPDU payload')
macFrame2.send(maximus)

# Send an MPDU containing 3 PBs of 512 octets
send_fcall3(sta)
macFrame3 = MACFrame()
macFrame3.set_fc_av(pack('IIII', 0, 456, 789, 10))
macFrame3.set_msdu(1500*'a')
macFrame3.send(maximus)

# Send a short PPDU with a FC 1.0
send_fcall4(sta)
macFrame4 = MACFrame()
macFrame4.set_fc_10(1)
macFrame4.set_fc_av(pack('IIII', 123, 456, 789, 10))
macFrame4.send(maximus, short_ppdu=True)

# Send an MPDU containing one PB of 512 octets with a FC 1.0
send_fcall5(sta)
macFrame5 = MACFrame()
macFrame5.set_fc_10(10)
macFrame5.set_fc_av(pack('IIII', 123, 456, 789, 10))
macFrame5.set_msdu(200*'b')
macFrame5.send(maximus)

# Send an MPDU containing one PB of 128 octets, created from an MME
send_fcall2(sta)
macFrame6 = MACFrame(MACFrameHeader='H!', ICV='ICV!')
macFrame6.set_fc_av(pack('IIII', 123, 456, 789, 10))
macFrame6.set_msdu(mme.MME(MMHeader='MMHeader 19 octets!', MMEntry='--- This is the Management Message Entry ---'))
macFrame6.send(maximus)

# Send an MPDU containing 236 PBs
send_fcall_236(sta)
macFrame6.set_msdu(512*'a')
macFrameQueue = MACFrameQueue()
for i in range (0,79):
    macFrameQueue.add(macFrame6)
macFrameQueue.send(maximus)

maximus.wait(10000)

fcall6 = maximus.create_fcall('uninit_phy')
fcall6.send(sta)

sta.remove()

print "\n*** END ***\n"