summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cesar/test_general/station/scenario/av/py/sc08_bentry_change.py80
1 files changed, 58 insertions, 22 deletions
diff --git a/cesar/test_general/station/scenario/av/py/sc08_bentry_change.py b/cesar/test_general/station/scenario/av/py/sc08_bentry_change.py
index c32acc3d78..6d33247ad6 100644
--- a/cesar/test_general/station/scenario/av/py/sc08_bentry_change.py
+++ b/cesar/test_general/station/scenario/av/py/sc08_bentry_change.py
@@ -40,6 +40,21 @@ def get_nek (csi, sta):
% (fcall.bind_param_n_u32 ("nek" + str (j))[0])
return EKS (eks, nek)
+def beacon_filter_bentry_snid_change (packet_list, direction, beacons_list):
+ """Filter the beacon with a beacon entry snid change among the packet
+ list."""
+ for i in packet_list:
+ vs_sniffer_ind = Ether (i.get ())
+ beacon = scammer.get_sniffed_mme (vs_sniffer_ind)
+ # Beacons from AVLN 1 are the transmitted ones i.e. 0 in direction
+ # field. The beacons from AVLN 2 are the received ones i.e. 1 in
+ # direction.
+ # We use the direction value as index of tables in this test.
+ if vs_sniffer_ind.direction == direction:
+ for j in beacon.bentry:
+ if j.header == scammer.BENTRY_HDR['CHANGE_SNID']:
+ beacons_list.append (beacon)
+
class TestBentryChange (unittest.TestCase):
"""Test beacon entry which have a coutdown.
"""
@@ -61,6 +76,28 @@ class TestBentryChange (unittest.TestCase):
self.csi.uninit_test_bed ()
self.csi.process_uninit ()
+ def beacon_check_countdown (self, beacons_list, countdown, forbid_snids):
+ """ In the beacon the CHANGE SNID beacon entry, it will verify the
+ countdown value and if the new SNID is not in the forbid SNID.
+ beacon_list: the list containing the beacons having the CHANGE SNID
+ bentry.
+ countdown: the initial countdown value.
+ forbid_snids: A list containing the SNID already in use which are
+ also those the CCo should not choose.
+
+ Result: Fail the test if the countdown is wrong or the snid is in the
+ forbid SNID.
+ """
+ countdown_init_val = countdown
+ for i in beacons_list:
+ for j in i.bentry:
+ if j.header == scammer.BENTRY_HDR['CHANGE_SNID']:
+ self.failUnless (j.sccd == countdown)
+ self.failUnless (j.newsnid not in forbid_snids)
+ countdown -= 1
+ if countdown == 0:
+ countdown = countdown_init_val
+
def bentry_check (self, beacon, bentry):
"""Test the bentry with the beacon.
beacon: the beacon to check inside.
@@ -150,36 +187,35 @@ class TestBentryChange (unittest.TestCase):
own.get_data (maximus, i.get_sta_cesar())
snids.append (own.snid)
del own
+ # We need to activate the sniffer for TX/RX beacons.
+ status = sniffer (maximus, ccos[0], beacon_tx = True,
+ beacon_rx = True)
+ self.failUnless (status)
# Change the SNID on AVLN 1.
fcall = maximus.create_fcall ("fc_cco_change_snid")
fcall.set_sta (ccos[0].get_sta_cesar().get())
fcall.add_param_ushort ('snid', snids[1])
fcall.send()
- # We need to activate the sniffer for TX/RX beacons.
- status = sniffer (maximus, ccos[0], beacon_tx = True,
- beacon_rx = True)
- self.failUnless (status)
- beacons = self.csi.sniff_packets (25)
- self.failUnless (beacons)
+ # We need to wait for some time, we will have to conflicts, the first
+ # one is that, with the fcall snid change, the second AVLN will change
+ # its SNID to the first AVLNs' one (This should never happen in the
+ # real life.
+ self.csi.process_wait_sec (10)
# Stop the sniffer.
status = sniffer (maximus, ccos[0])
self.failUnless (status)
- # Process the beacons.
- countdown = [5, 5]
- for i in beacons:
- vs_sniffer_ind = Ether (i.get ())
- beacon = scammer.get_sniffed_mme (vs_sniffer_ind)
- # Beacons from AVLN 1 are the transmitted ones i.e. 0 in direction
- # field. The beacons from AVLN 2 are the received ones i.e. 1 in
- # direction.
- # We use the direction value as index of tables in this test.
- for j in beacon.bentry:
- if j.header == scammer.BENTRY_HDR['CHANGE_SNID']:
- self.failUnless (j.sccd ==
- countdown[vs_sniffer_ind.direction])
- self.failUnless (j.newsnid not in snids)
- countdown[vs_sniffer_ind.direction] -= 1
- self.failUnless (countdown == [0, 0])
+ # Process the beacons. We should have two conflict so too loops.
+ beacons_tx = list ()
+ beacons_rx = list ()
+ beacon_filter_bentry_snid_change (self.csi.sniffed_packets, 0,
+ beacons_tx)
+ beacon_filter_bentry_snid_change (self.csi.sniffed_packets, 1,
+ beacons_rx)
+ # We can verify. For TX there is a special case as the sniffer is
+ # configured for this station, it will first change the snid to the
+ # other AVLN SNID before changing it again cause of the conflict.
+ self.beacon_check_countdown (beacons_tx, 5, [snids[0]])
+ self.beacon_check_countdown (beacons_rx, 5, snids)
# Now we verify the SNID is correctly set in the CCo.
snids_new = []
own = Station_own_data ()