summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlaranjeiro2010-07-06 10:12:08 +0000
committerlaranjeiro2010-07-06 10:12:08 +0000
commita23cfac9536cdc570343efd23d40d79345e59ecb (patch)
tree48c01564cc54124aaf9df29090a0e6483f8d76e3
parent48528032239c2007428059721e305ca2974dcf87 (diff)
cesar/cp/{beacon, sta/mgr}: change snid conflict detection, closes #1695
Previously the sta_mgr was checking the snid conflict, this was causing the CCo to continuously change the SNID (even after a SNID countdown beacon entry). Now CP beacon is responsible to detect it and inform the CCo action module, It only posts the event if now snid countdown is currently done. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@7266 017c9cb6-072f-447c-8318-d5b54f68fe89
-rw-r--r--cesar/bsu/src/bsu.c87
-rw-r--r--cesar/cp/beacon/src/beacon.c10
-rw-r--r--cesar/cp/sta/mgr/src/sta_mgr.c8
-rw-r--r--cesar/test_general/station/cco0/s2/py/sc06_snid_conflict.py114
4 files changed, 99 insertions, 120 deletions
diff --git a/cesar/bsu/src/bsu.c b/cesar/bsu/src/bsu.c
index 40df3f5165..cd85108b9c 100644
--- a/cesar/bsu/src/bsu.c
+++ b/cesar/bsu/src/bsu.c
@@ -374,6 +374,17 @@ bsu_avln_schedules_decrease_countdown (bsu_t *ctx, bsu_avln_t *avln)
avln->bs.schedules.ps.ps[i].cscd--;
}
}
+ /* Special case, the SNID of our network change. */
+ if (ctx->sta_avln == avln
+ && avln->bs.schedules.snid[0] != avln->bs.schedules.snid[1])
+ ctx->snid_track = avln->bs.schedules.snid[1];
+ /* Countdown all. */
+ for (i = 0; i < BSU_BEACON_SCHEDULES_MAX - 1; i++)
+ {
+ avln->bs.schedules.snid[i] = avln->bs.schedules.snid[i+1];
+ avln->bs.schedules.hm[i] = avln->bs.schedules.hm[i+1];
+ avln->bs.schedules.nek_switch[i] = avln->bs.schedules.nek_switch[i+1];
+ }
}
/**
@@ -443,43 +454,52 @@ bsu_timer_event_process (void *ud)
static inline void
bsu_update_sta_avln_schedules (bsu_t *ctx)
{
+ /* Copy schedules. */
+ ctx->sta_avln->bs.schedules.ps = ctx->beacon.bmis.ps;
+ ctx->sta_avln->bs.schedules.nps = ctx->beacon.bmis.nps;
+ ctx->sta_avln->bs.schedules.bpsto = ctx->beacon.bmis.bpsto;
+ /* Countdown all. */
uint i;
- /* Coexistence mode */
- if (ctx->beacon.bmis.change_hm.present)
+ for (i = 0; i < BSU_BEACON_SCHEDULES_MAX - 1; i++)
+ {
+ ctx->sta_avln->bs.schedules.snid[i] =
+ ctx->sta_avln->bs.schedules.snid[i+1];
+ ctx->sta_avln->bs.schedules.hm[i] =
+ ctx->sta_avln->bs.schedules.hm[i+1];
+ ctx->sta_avln->bs.schedules.nek_switch[i] =
+ ctx->sta_avln->bs.schedules.nek_switch[i+1];
+ }
+ /* Coexistence mode
+ * Because only the CCo call this function and it will
+ * set the CA schedule with this value before the countdown ends in the
+ * central beacon. */
+ if (ctx->beacon.bmis.change_hm.present
+ && ctx->beacon.bmis.change_hm.hmccd == 1)
{
- ctx->sta_avln->bs.schedules.hm[0] = ctx->beacon.vf.hm;
- for (i = ctx->beacon.bmis.change_hm.hmccd;
- i < COUNT (ctx->sta_avln->bs.schedules.hm);
- i++)
- ctx->sta_avln->bs.schedules.hm[i] =
- ctx->beacon.bmis.change_hm.newhm;
+ ctx->sta_avln->bs.schedules.hm[BSU_BEACON_SCHEDULES_MAX - 1] =
+ ctx->beacon.vf.hm;
}
- /* NEK switch. */
+ /* NEK switch.
+ * Because only the CCo call this function and it will
+ * set the CA schedule with this value before the countdown ends in the
+ * central beacon. */
if (ctx->beacon.bmis.eks.present
- && ctx->beacon.bmis.eks.kbc == BSU_BEACON_EKS_KBC_NEK)
+ && ctx->beacon.bmis.eks.kbc == BSU_BEACON_EKS_KBC_NEK
+ && ctx->beacon.bmis.eks.kccd == 1)
{
- for (i = ctx->beacon.bmis.eks.kccd;
- i < COUNT (ctx->sta_avln->bs.schedules.nek_switch);
- i++)
- ctx->sta_avln->bs.schedules.nek_switch[i] =
- ctx->beacon.bmis.eks.new_eks;
+ ctx->sta_avln->bs.schedules.nek_switch[BSU_BEACON_SCHEDULES_MAX - 1] =
+ ctx->beacon.bmis.eks.new_eks;
}
- /* SNID change. */
- if (ctx->beacon.bmis.change_snid.present)
+ /* SNID change.
+ * Because only the CCo call this function and it will
+ * set the CA schedule with this value before the countdown ends in the
+ * central beacon. */
+ if (ctx->beacon.bmis.change_snid.present
+ && ctx->beacon.bmis.change_snid.snidccd == 1)
{
- for (i = ctx->beacon.bmis.change_snid.snidccd;
- i < COUNT (ctx->sta_avln->bs.schedules.snid);
- i++)
- ctx->sta_avln->bs.schedules.snid[i] =
- ctx->beacon.bmis.change_snid.new_snid;
- if (ctx->beacon.bmis.change_snid.snidccd == 0)
- ctx->sta_avln->bs.snid =
- ctx->beacon.bmis.change_snid.new_snid;
+ ctx->sta_avln->bs.schedules.snid[BSU_BEACON_SCHEDULES_MAX-1] =
+ ctx->beacon.bmis.change_snid.new_snid;
}
- /* Copy schedules. */
- ctx->sta_avln->bs.schedules.ps = ctx->beacon.bmis.ps;
- ctx->sta_avln->bs.schedules.nps = ctx->beacon.bmis.nps;
- ctx->sta_avln->bs.schedules.bpsto = ctx->beacon.bmis.bpsto;
}
bsu_t *
@@ -705,6 +725,15 @@ bsu_update (bsu_beacon_t *beacon, bsu_update_sta_type_t is_sta)
&& beacon->bmis.ps.ps[0].pscd
< beacon->bmis.ps.ps[1].pscd));
dbg_assert (beacon->vf.hm < MAC_COEXISTENCE_NB);
+ /* Reset tracking data if is CCo. */
+ if (ctx->is_sta != is_sta
+ && is_sta == BSU_UPDATE_STA_TYPE_CCO)
+ {
+ ctx->nid_track = 0;
+ ctx->snid_track = 0;
+ ctx->tei_track = 0;
+ ctx->sta_avln = &ctx->poweron;
+ }
/* If the data provided are for the next beacon period. */
if (lesseq_mod2p32 (bsu_aclf_beacon_period_start_date_next (ctx->aclf),
beacon->beacon_period_start_date)
diff --git a/cesar/cp/beacon/src/beacon.c b/cesar/cp/beacon/src/beacon.c
index 4c31ba206e..bfe28f3876 100644
--- a/cesar/cp/beacon/src/beacon.c
+++ b/cesar/cp/beacon/src/beacon.c
@@ -704,7 +704,6 @@ cp_beacon_get_and_process_beacon (cp_t *ctx)
cp_net_set_access (ctx, net, bsu_params->rx_parameters.access);
cp_net_set_slot_id_and_usage (ctx, net, beacon_data.vf.slotid,
beacon_data.vf.slotusage);
-
dbg_assert (tei == MAC_TEI_UNASSOCIATED || MAC_TEI_IS_STA (tei));
sta = cp_beacon_update_sta_peer (ctx, &beacon_data, net, type, tei,
mac_address);
@@ -754,6 +753,15 @@ cp_beacon_get_and_process_beacon (cp_t *ctx)
/** Program the timer. */
cp_beacon_reconfigure_timer (ctx, false);
}
+ else if (cp_sta_own_data_get_tei (ctx))
+ {
+ /* Is the SNID in conflict. */
+ cp_net_t *our_net = cp_sta_mgr_get_our_avln (ctx);
+ if (our_net != net
+ && cp_net_get_snid (ctx, our_net) == cp_net_get_snid (ctx, net)
+ && ctx->beacon.snids.snidcd == 0)
+ cp_fsm_post_new_event (ctx, bare, snid_conflict);
+ }
/** Raise the event in the FSM for station action. */
cp_fsm_post_new_event (ctx, beacon, BEACON,
diff --git a/cesar/cp/sta/mgr/src/sta_mgr.c b/cesar/cp/sta/mgr/src/sta_mgr.c
index 0bd843c45f..5513eb1091 100644
--- a/cesar/cp/sta/mgr/src/sta_mgr.c
+++ b/cesar/cp/sta/mgr/src/sta_mgr.c
@@ -282,14 +282,6 @@ cp_sta_mgr_add_avln (cp_t *ctx, cp_snid_t snid, cp_nid_t nid)
dbg_assert (ctx);
dbg_assert (nid);
- // Verify SNID collisions.
- if (ctx->sta_mgr.our_avln
- && (cp_net_get_nid (ctx, ctx->sta_mgr.our_avln) != nid)
- && (cp_net_get_snid (ctx, ctx->sta_mgr.our_avln) == snid))
- {
- cp_fsm_trigger_new_event (ctx, bare, snid_conflict);
- }
-
/* Our avln do not search in the list. */
if (ctx->sta_mgr.our_avln
&& (cp_net_get_nid (ctx, ctx->sta_mgr.our_avln) == nid)
diff --git a/cesar/test_general/station/cco0/s2/py/sc06_snid_conflict.py b/cesar/test_general/station/cco0/s2/py/sc06_snid_conflict.py
index d7246f14aa..13b7698c8a 100644
--- a/cesar/test_general/station/cco0/s2/py/sc06_snid_conflict.py
+++ b/cesar/test_general/station/cco0/s2/py/sc06_snid_conflict.py
@@ -15,32 +15,29 @@ from beacon import *
csi = csiCore (1234)
+MACSDEFAULT = "00:13:d7:00:0%x:%02x"
+
# Creating an AVLN.
avln1 = csi.avln_add ("Homeplug_AVLN1", "AVLN1")
-avln2 = csi.avln_add ("Homeplug_AVLN2", "AVLN2")
+avln1_sta_nb = 2
-avln1_sta1_debug = False
-avln1_sta2_debug = False
-
-avln2_sta1_debug = False
-avln2_sta2_debug = False
+avln2 = csi.avln_add ("Homeplug_AVLN2", "AVLN2")
+avln2_sta_nb = 2
# Adding the stations.
avln1_stas = list ()
-avln1_stas.append (avln1.sta_add ("00:00:00:00:01:01", False, False,
- "HomePlug_AVLN1_Station1", "av1_spc300_sta1", "avln1_station1", 1,
- avln1_sta1_debug))
-avln1_stas.append (avln1.sta_add ("00:00:00:00:01:02", False, False,
- "HomePlug_AVLN1_Station2", "av1_spc300_sta2", "avln1_station2", 1,
- avln1_sta2_debug))
+for i in range (0, avln1_sta_nb):
+ avln1_stas.append (avln1.sta_add (MACSDEFAULT % (1, i+1), False, False,
+ "HomePlug_AVLN1_Station%d" % (i+1),
+ "av1_spc300_sta%d" % (i+1),
+ "avln1_station%d" % (i+1), 1, False))
avln2_stas = list ()
-avln2_stas.append (avln2.sta_add ("00:00:00:00:02:01", False, False,
- "HomePlug_AVLN2_Station1", "av2_spc300_sta1", "avln2_station1", 1,
- avln2_sta1_debug))
-avln2_stas.append (avln2.sta_add ("00:00:00:00:02:02", False, False,
- "HomePlug_AVLN2_Station2", "av2_spc300_sta2", "avln2_station2", 1,
- avln2_sta2_debug))
+for i in range (0, avln2_sta_nb):
+ avln2_stas.append (avln2.sta_add (MACSDEFAULT % (2, i+1), False, False,
+ "HomePlug_AVLN2_Station%d" % (i+1),
+ "av2_spc300_sta%d" % (i+1),
+ "avln2_station%d" % (i+1), 1, False))
csi.process_init (sys.argv + ['-e' , 'obj/cco0s2.elf'])
csi.process_avlns_launch ()
@@ -62,99 +59,52 @@ class TestSnidChange(unittest.TestCase):
pass
def testSnidDiff (self):
- print ""
-
+ """Set the same SNID in the AVLN using Fcalls, CCo should change the
+ SNID."""
# Get the snid of the first AVLN.
own = Station_own_data ()
own.get_data (csi.get_maximus (), avln1_stas[1].get_sta_cesar())
avln1_snid = own.snid
own = None
- print "AVLN 1 SNID : ", avln1_snid
-
- # Get the snid of the second AVLN.
- own = Station_own_data ()
- own.get_data (csi.get_maximus (), avln2_stas[1].get_sta_cesar())
- avln2_snid = own.snid
- own = None
- print "AVLN 2 SNID : ", avln2_snid
-
- # Activate the sniffer for the beacon TX on the CCo of the first AVLN.
- state = csi.sniffer_activate (avln1_stas[1], False, False, True, False)
- if state == False:
- print "Sniffer not activated for AVLN 1 Sta 2"
-
- fcall = csi.get_maximus().create_fcall ("fc_cco_change_snid")
- fcall.set_sta (avln1_stas[1].get_sta_cesar().get())
- fcall.add_param_ushort ('snid', avln1_snid + 1)
- fcall.send()
-
- # Wait 1 seconds.
- csi.process_wait_sec (1)
- own = Station_own_data ()
- own.get_data (csi.get_maximus (), avln1_stas[1].get_sta_cesar())
- avln1_snid = own.snid
-
- own = Station_own_data ()
- own.get_data (csi.get_maximus (), avln1_stas[0].get_sta_cesar())
- avln2_snid = own.snid
-
- self.failUnless (avln1_snid != avln2_snid)
-
- def testSnideq (self):
print ""
-
- # Get the snid of the first AVLN.
- own = Station_own_data ()
- own.get_data (csi.get_maximus (), avln1_stas[1].get_sta_cesar())
- avln1_snid = own.snid
- own = None
print "AVLN 1 SNID : ", avln1_snid
-
# Get the snid of the second AVLN.
own = Station_own_data ()
own.get_data (csi.get_maximus (), avln2_stas[1].get_sta_cesar())
avln2_snid = own.snid
own = None
print "AVLN 2 SNID : ", avln2_snid
-
fcall = csi.get_maximus().create_fcall ("fc_cco_change_snid")
fcall.set_sta (avln1_stas[1].get_sta_cesar().get())
- fcall.add_param_ushort ('snid', avln2_snid)
+ fcall.add_param_ushort ('snid', avln1_snid + 1)
fcall.send()
-
- beacon = csi.sniff_packets (1)
-
- # Wait 1 seconds.
- csi.process_wait_sec (0.2)
- beacon2 = csi.sniff_packets (1)
-
- self.failUnless (beacon != None)
- unpack = Beacon ()
- unpack.unpack (beacon[0].get())
- self.failUnless (unpack.change_snid_snid == avln2_snid)
- unpack = None
-
- self.failUnless (beacon2 != None)
- unpack = Beacon()
- unpack.unpack (beacon2[0].get())
- self.failUnless (unpack.change_snid_snid == 0)
-
+ csi.process_wait_sec (2)
own = Station_own_data ()
own.get_data (csi.get_maximus (), avln1_stas[1].get_sta_cesar())
avln1_snid = own.snid
print "AVLN 1 SNID : ", avln1_snid
-
own = Station_own_data ()
- own.get_data (csi.get_maximus (), avln2_stas[1].get_sta_cesar())
+ own.get_data (csi.get_maximus (), avln2_stas[0].get_sta_cesar())
avln2_snid = own.snid
print "AVLN 2 SNID : ", avln2_snid
-
self.failUnless (avln1_snid != avln2_snid)
+ # Send data over the two AVLN 1.
+ from csipacket import csiPacket
+ for i in [avln1, avln2]:
+ stationsrc = i.get_sta (0)
+ stationdst = i.get_sta (1)
+ p = csiPacket (1024, i, stationsrc, stationsrc.get_mac_addr (),
+ stationdst)
+ csi.process_data_send (p)
+ csi.process_wait_sec (1)
+ csi.process_verify_transmission ()
suite = unittest.TestLoader().loadTestsFromTestCase(TestSnidChange)
testResult = unittest.TextTestRunner(verbosity=2).run(suite)
+csi.process_avlns_stop ()
csi.process_avlns_remove ()
# For nightly build errors
sys.exit ((1, 0)[testResult.wasSuccessful ()])
+os.system ("killall cco0s2.elf")