summaryrefslogtreecommitdiff
path: root/cesar/bsu
diff options
context:
space:
mode:
authorlaranjeiro2010-07-22 08:40:45 +0000
committerlaranjeiro2010-07-22 08:40:45 +0000
commitdf052ada107010e544918a6319db94762ea08476 (patch)
treedba5911528cce1aa7a6b1f225ac821e6d4477d92 /cesar/bsu
parent0665ce40cb403c93eb131e48ea4972588ed11386 (diff)
cesar/bsu: add CSMA only verification
If a central beacon is received with a schedule which is not persistent, replace it by a permanent schedule with only a CSMA SAI. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@7306 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/bsu')
-rw-r--r--cesar/bsu/src/bsu.c37
-rw-r--r--cesar/bsu/test/utest/src/schedules.c55
2 files changed, 92 insertions, 0 deletions
diff --git a/cesar/bsu/src/bsu.c b/cesar/bsu/src/bsu.c
index 07136a808d..4d50851377 100644
--- a/cesar/bsu/src/bsu.c
+++ b/cesar/bsu/src/bsu.c
@@ -312,6 +312,42 @@ bsu_schedules_merge (bsu_t *ctx, bsu_beacon_schedules_t *asched,
}
/**
+ * If the network is in CSMA only mode, check the current schedule is
+ * permanent and with a full CSMA period.
+ * \param ctx the module context.
+ * \param schedule the schedule for the current and next beacon periods.
+ *
+ * If the schedules are not compatible with the network mode, the default will
+ * be applied.
+ */
+inline void
+bsu_ca_schedules_nm_csma_only (bsu_t *ctx, bsu_beacon_schedules_t *schedule)
+{
+ if (schedule->nm == BSU_BEACON_NM_CSMA_ONLY)
+ {
+ if (schedule->ps.nb == 0
+ || !(schedule->ps.nb == 1
+ && schedule->ps.ps[0].pscd ==
+ BSU_BEACON_PERSISTENT_SCHEDULES_PERMANENT_COUNTDOWN
+ && schedule->ps.ps[0].cscd ==
+ BSU_BEACON_PERSISTENT_SCHEDULES_PERMANENT_COUNTDOWN))
+ {
+ schedule->nps.ns = 0;
+ schedule->ps.nb = 1;
+ schedule->ps.ps[0].ns = 1;
+ schedule->ps.ps[0].pscd =
+ BSU_BEACON_PERSISTENT_SCHEDULES_PERMANENT_COUNTDOWN;
+ schedule->ps.ps[0].cscd =
+ BSU_BEACON_PERSISTENT_SCHEDULES_PERMANENT_COUNTDOWN;
+ schedule->ps.ps[0].sais[0].stpf = false;
+ schedule->ps.ps[0].sais[0].end_time_atu =
+ bsu_aclf_beacon_period_atu (ctx->aclf);
+ schedule->ps.ps[0].sais[0].glid = MAC_LID_SHARED_CSMA & 0x7f;
+ }
+ }
+}
+
+/**
* End to fill the schedules and provide it to the CA.
* \param ctx the module context.
* \param avln the station avln data containing the schedules read from the
@@ -331,6 +367,7 @@ bsu_ca_schedules (bsu_t *ctx, bsu_avln_t *avln)
u32 bpsd[BSU_BEACON_SCHEDULES_MAX];
uint i;
bsu_aclf_beacon_period_start_date (ctx->aclf, bpsd, COUNT (bpsd));
+ bsu_ca_schedules_nm_csma_only (ctx, &avln->bs.schedules);
/* Get the CA schedules from the next one and for BPSD_NB. */
for (i = 0; i < COUNT (bpsd); i++)
{
diff --git a/cesar/bsu/test/utest/src/schedules.c b/cesar/bsu/test/utest/src/schedules.c
index 4ca917f3a7..a18ceb6527 100644
--- a/cesar/bsu/test/utest/src/schedules.c
+++ b/cesar/bsu/test/utest/src/schedules.c
@@ -18,6 +18,7 @@
#include "bsu/inc/bsu.h"
#include "bsu/inc/context.h"
#include "bsu/inc/interface.h"
+#include <string.h>
void
bsu_schedules_merge (bsu_t *ctx, bsu_beacon_schedules_t *avln,
@@ -223,9 +224,63 @@ test_case_bsu_schedules_countdowns (test_t t)
}
void
+test_case_ca_schedules_intellon (test_t test)
+{
+ test_case_begin (test, "Intellon central beacons");
+ test_begin (
+ test, "Persistent schedule valid for the current beacon period")
+ {
+ bsu_test_t t;
+ bsu_test_init (&t);
+ bsu_beacon_t beacon;
+ pb_beacon_t *pbbeacon;
+ bsu_test_create_beacon (&t, &beacon);
+ beacon.bmis.nps.ns = 0;
+ beacon.bmis.ps.nb = 1;
+ beacon.bmis.ps.ps[0].ns = 1;
+ beacon.bmis.ps.ps[0].pscd = 0;
+ beacon.bmis.ps.ps[0].cscd = 0;
+ beacon.bmis.ps.ps[0].sais[0].stpf = true;
+ beacon.bmis.ps.ps[0].sais[0].start_time_atu = 52;
+ beacon.bmis.ps.ps[0].sais[0].end_time_atu = 3907;
+ beacon.bmis.ps.ps[0].sais[0].glid = MAC_LID_SHARED_CSMA & 0x7f;
+ uint i;
+ for (i = 0; i < COUNT (t.bsu->aclf->bpsd); i++)
+ t.bsu->aclf->bpsd[i] = i * BSU_ACLF_BP_50HZ_TCK;
+ t.bsu->aclf->beacon_period = BSU_ACLF_BP_50HZ_TCK;
+ *((uint*) &t.bsu->aclf->bp) = BSU_ACLF_BP_50HZ_TCK;
+ pbproc_tx_beacon_params_t btx;
+ pbproc_rx_beacon_params_t brx;
+ memset (&brx, 0, sizeof (pbproc_rx_beacon_params_t));
+ pbbeacon = bsu_beacon_write (
+ &beacon, BSU_BEACON_TYPE_CENTRAL, &t.mac_config, &btx);
+ pbbeacon->phy_pb.pb_rx.pb_measurement.crc_error = false;
+ bsu_track_avln (beacon.vf.nid, brx.snid, 0, beacon.vf.nm);
+ t.bsu->is_sta = BSU_UPDATE_STA_TYPE_STA;
+ bsu_beacon_process (t.bsu, pbbeacon, &brx);
+ /* Schedules which should be present. */
+ test_fail_unless (t.bsu->sta_avln->bs.schedules.ps.nb == 1);
+ test_fail_unless (t.bsu->sta_avln->bs.schedules.ps.ps[0].pscd == 7);
+ test_fail_unless (t.bsu->sta_avln->bs.schedules.ps.ps[0].cscd == 7);
+ test_fail_unless (
+ t.bsu->sta_avln->bs.schedules.ps.ps[0].sais[0].glid ==
+ (MAC_LID_SHARED_CSMA & 0x7f));
+ test_fail_unless (
+ t.bsu->sta_avln->bs.schedules.ps.ps[0].sais[0].end_time_atu ==
+ 3907);
+ test_fail_unless (
+ t.bsu->sta_avln->bs.schedules.ps.ps[0].sais[0].stpf == false);
+ blk_release_desc ((blk_t*) pbbeacon);
+ bsu_test_uninit (&t);
+ }
+ test_end;
+}
+
+void
test_suite_bsu_schedule (test_t t)
{
test_suite_begin (t, "BSU schedules");
test_case_ca_schedules (t);
test_case_bsu_schedules_countdowns (t);
+ test_case_ca_schedules_intellon (t);
}