summaryrefslogtreecommitdiff
path: root/cesar/cp
diff options
context:
space:
mode:
authorJean-Philippe SAVE2011-04-13 10:09:31 +0200
committerJean-Philippe SAVE2011-04-13 10:09:31 +0200
commit99e2743b4cdebec66f4626b98ae53f8c168029bd (patch)
treee19d7c856425ec91d30a0b70a62551be9f64ba9c /cesar/cp
parent5a1b71306f2606d2bf04812215c226e6d29159c0 (diff)
Revert "cesar/cp/sta/mgr: restore partial ack, closes #214"
This reverts commit 57296857010d3577d0eb5e135130881c9ba75777.
Diffstat (limited to 'cesar/cp')
-rw-r--r--cesar/cp/sta/mgr/src/sta_mgr.c75
-rw-r--r--cesar/cp/sta/mgr/test/src/sta_mgr.c191
2 files changed, 201 insertions, 65 deletions
diff --git a/cesar/cp/sta/mgr/src/sta_mgr.c b/cesar/cp/sta/mgr/src/sta_mgr.c
index db87928fda..a05739828c 100644
--- a/cesar/cp/sta/mgr/src/sta_mgr.c
+++ b/cesar/cp/sta/mgr/src/sta_mgr.c
@@ -35,33 +35,64 @@
* station to which the packet is send.
* \param ctx the module context.
*
- * This function choose the station randomly on the network.
+ * This function choose the station using the data of the tone maps in the
+ * station contained in the mac store. It shall insert in the mac config the
+ * station's TEI which will acknowledge the packets.
+ * The station manager is responsible to elects another station if the current
+ * one is removed or if another one shall become the acknowledge station.
*/
void
cp_sta_mgr_elects_sta_partial_ack (cp_t *ctx)
{
dbg_assert (ctx);
- cp_net_t *net = ctx->sta_mgr.our_avln;
- if (net)
- {
- cp_sta_t *sta;
- u8 *tei_table = blk_alloc ();
- uint tei_nb = 0;
- /* Get all the TEI of the network and store it into the tei table. */
- /* Store the TEI of the station. */
- for (sta = cp_net_sta_get_first (ctx, net, CP_NET_STA_ASSOC);
- sta;
- sta = cp_net_sta_get_next (ctx, net, sta))
- tei_table[tei_nb++] = cp_sta_get_tei (sta);
- if (tei_nb)
- {
- /* Choose the TEI of the partial ACK station, */
- uint pos = lib_rnd_uniform (&ctx->rnd, tei_nb);
- ctx->mac_config->partial_ack_tei_default = tei_table[pos];
- }
- /* Release the block used. */
- blk_release (tei_table);
- }
+
+ /* FIXME:To be correctly specified, the BLE seems to not be a good
+ * criteria for the partial ack, when we only have ROBO tonemap the BLE
+ * is the same for all the stations. */
+// /* Do nothing if your AVLN is not set. */
+// if (ctx->sta_mgr.our_avln != NULL)
+// {
+// cp_sta_t *sta;
+// sta_t *sta_store;
+//
+// dbg_assert (ctx->mac_store);
+// dbg_assert (ctx->mac_config);
+//
+// /* The BLE is a 8 bits long field. */
+// uint ble = 0x100;
+// cp_tei_t sta_tei = MAC_TEI_UNASSOCIATED;
+//
+// /* Parse the station manager for all the station present in our AVLN.
+// * The one which as the lesser BLE will be choose to be the partial
+// * ack's station. */
+// for (sta = cp_net_sta_get_first (ctx, ctx->sta_mgr.our_avln,
+// CP_NET_STA_ASSOC);
+// sta;
+// sta = cp_net_sta_get_next (ctx, ctx->sta_mgr.our_avln, sta))
+// {
+// /* Get the station from the mac store. */
+// sta_store = mac_store_sta_get (ctx->mac_store, cp_sta_get_tei
+// (sta));
+// dbg_assert (sta_store);
+// if (sta_store->tx_tonemaps
+// && (sta_store->tx_tonemaps->default_tmi < TONEMAP_INDEX_NB))
+// {
+// uint tmi = sta_store->tx_tonemaps->default_tmi;
+//
+// if (ble > sta_store->tx_tonemaps->tm[tmi]->ble)
+// {
+// ble = sta_store->tx_tonemaps->tm[tmi]->ble;
+// sta_tei = cp_sta_get_tei (sta);
+// }
+// }
+//
+// blk_release (sta_store);
+// }
+//
+// /* Store the TEI of the station. */
+// if (sta_tei != MAC_TEI_UNASSOCIATED)
+// ctx->mac_config->partial_ack_tei_default = sta_tei;
+// }
}
/**
diff --git a/cesar/cp/sta/mgr/test/src/sta_mgr.c b/cesar/cp/sta/mgr/test/src/sta_mgr.c
index fde37c53a6..aeeba2109f 100644
--- a/cesar/cp/sta/mgr/test/src/sta_mgr.c
+++ b/cesar/cp/sta/mgr/test/src/sta_mgr.c
@@ -979,11 +979,19 @@ test_case__cp_net_is_empty (test_t test)
test_begin (test, "Network is empty")
{
cp_t cp;
+ cl_t cl;
+ sar_t sar;
cp_net_t *net;
cp_sta_t *sta;
uint i;
/* configuring the test. */
- test_sta_mgr_init (&cp);
+ memset (&cp, 0, sizeof (cp_t));
+ cp.sar = &sar;
+ cp.cl = &cl;
+ cl.mactotei = NULL;
+ sar.mac_store = mac_store_init ();
+ cp.mac_store = sar.mac_store;
+ cp_sta_mgr_init (&cp);
test_fail_unless (cp_sta_mgr_net_list_is_empty (&cp) == true);
for (i = 0; i < HPAV_AVLNS_NB_MAX; i++)
{
@@ -1020,7 +1028,7 @@ test_case__cp_net_is_empty (test_t test)
test_fail_unless (cp_sta_mgr_net_list_is_empty (&cp) == true);
net->present = true;
test_fail_unless (cp_sta_mgr_net_list_is_empty (&cp) == true);
- test_sta_mgr_uninit (&cp);
+ cp_sta_mgr_uninit (&cp);
}
test_end;
}
@@ -1360,47 +1368,144 @@ void
test_case__cp_sta_mgr_partial_ack (test_t test)
{
test_case_begin (test, "Partial acknowledge");
- cp_t cp;
- test_sta_mgr_init (&cp);
- cp_net_t *net = cp_sta_mgr_add_avln (&cp, 1, 1);
- cp_sta_mgr_set_our_avln (&cp, net);
- cp_sta_own_data_set_tei (&cp, 254);
- test_begin (test, "No STA")
- {
- cp_sta_mgr_elects_sta_partial_ack (&cp);
- test_fail_unless (cp.mac_config->partial_ack_tei_default
- == MAC_TEI_UNASSOCIATED);
- }
- test_end;
- test_begin (test, "Single STA")
- {
- uint i;
- cp_sta_t *sta = cp_sta_mgr_sta_add (&cp, net, 1, 1);
- for (i = 0; i < 20; i++)
- {
- cp_sta_mgr_elects_sta_partial_ack (&cp);
- test_fail_unless (cp.mac_config->partial_ack_tei_default
- == cp_sta_get_tei (sta));
- }
- slab_release (sta);
- }
- test_end;
- test_begin (test, "Two STA")
- {
- uint i;
- cp_sta_t *sta = cp_sta_mgr_sta_add (&cp, net, 2, 2);
- cp_tei_t tei_cmp[] = { 1, 1, 1, 2, 1, 2, 2, 1, 1, 2, 1, 1, 2, 1, 2, 1,
- 1, 1, 2, 2 };
- for (i = 0; i < 20; i++)
- {
- cp_sta_mgr_elects_sta_partial_ack (&cp);
- test_fail_unless (cp.mac_config->partial_ack_tei_default ==
- tei_cmp[i]);
- }
- slab_release (sta);
- }
- test_end;
- test_sta_mgr_uninit (&cp);
+
+// test_begin (test, "Partial ACK")
+// {
+// cp_t cp;
+// cl_t cl;
+// sar_t sar;
+// mac_config_t mac_config;
+// cp_net_t *net;
+// cp_sta_t *sta;
+// sta_t *sta_store;
+// uint i;
+// uint nbsta = 10;
+// lib_rnd_t rand;
+//
+// memset (&cl, 0, sizeof (cl_t));
+// memset (&sar, 0, sizeof (sar_t));
+// memset (&mac_config, 0, sizeof (mac_config_t));
+// cp_sta_mgr_init (&cp);
+// cp.mac_store = mac_store_init ();
+// cp.cl = (cl_t *) &cl;
+// cp.sar = &sar;
+// sar.mac_store = cp.mac_store;
+// cp.mac_config = &mac_config;
+//
+// lib_rnd_init (&rand, 0x123);
+// memset (&mac_config, 0, sizeof (mac_config));
+//
+// /* First test, elects a station when our station does not makes part
+// * of any AVLN. */
+// cp_sta_mgr_elects_sta_partial_ack (&cp);
+// test_fail_unless (mac_config.partial_ack_tei_default == 0);
+//
+// /* Add the AVLN and configure it as our AVLN. */
+// net = cp_sta_mgr_add_avln (&cp, 1, 1);
+// cp_sta_mgr_set_our_avln (&cp, net);
+//
+// /* Create some stations. */
+// for (i = 1; i < nbsta; i++)
+// {
+// /* Add the station in the station manager and at the same time in
+// * the mac store. */
+// sta = cp_sta_mgr_sta_add (&cp, net, i, i);
+//
+// /* Get the station from the mac store. */
+// sta_store = mac_store_sta_get (cp.mac_store, i);
+// dbg_assert (sta_store);
+//
+// /* Modify the default tone map to configure the BLE.*/
+// if (sta_store->tx_tonemaps)
+// {
+// /* Allocate the tone map. */
+// sta_store->tx_tonemaps->tm[4] = tonemap_alloc ();
+// sta_store->tx_tonemaps->default_tmi = 4;
+// sta_store->tx_tonemaps->tm[4]->ble = lib_rnd32 (&rand);
+// }
+//
+// blk_release (sta_store);
+// slab_release (sta);
+// }
+//
+// cp_sta_mgr_elects_sta_partial_ack (&cp);
+// test_fail_unless (mac_config.partial_ack_tei_default == 2);
+//
+// /* Modify the BLE for station 2. */
+// sta_store = mac_store_sta_get (cp.mac_store, 2);
+// dbg_assert (sta_store);
+// sta_store->tx_tonemaps->tm[0]->ble = 51;
+// blk_release (sta_store);
+//
+// cp_sta_mgr_elects_sta_partial_ack (&cp);
+// test_fail_unless (mac_config.partial_ack_tei_default == 3);
+//
+//
+// /* Removes the current acknowledge station from the network. */
+// cp_sta_mgr_sta_remove_assoc (&cp, net, 3);
+// test_fail_unless (mac_config.partial_ack_tei_default == 8);
+//
+// /* Ends the test. */
+// cp_sta_mgr_set_our_avln (&cp, NULL);
+//
+// mac_store_uninit (cp.mac_store);
+// cp_sta_mgr_uninit (&cp);
+// }
+// test_end;
+//
+// test_begin (test, "Partial ACK no Tone maps")
+// {
+// cp_t cp;
+// cl_t cl;
+// sar_t sar;
+// mac_config_t mac_config;
+// cp_net_t *net;
+// cp_sta_t *sta;
+// uint i;
+// uint nbsta = 10;
+// lib_rnd_t rand;
+//
+// memset (&cl, 0, sizeof (cl_t));
+// memset (&sar, 0, sizeof (sar_t));
+// memset (&mac_config, 0, sizeof (mac_config_t));
+// cp_sta_mgr_init (&cp);
+// cp.mac_store = mac_store_init ();
+// cp.cl = (cl_t *) &cl;
+// cp.sar = &sar;
+// sar.mac_store = cp.mac_store;
+// cp.mac_config = &mac_config;
+//
+// lib_rnd_init (&rand, 0x123);
+// memset (&mac_config, 0, sizeof (mac_config));
+//
+// /* First test, elects a station when our station does not makes part
+// * of any AVLN. */
+// cp_sta_mgr_elects_sta_partial_ack (&cp);
+// test_fail_unless (mac_config.partial_ack_tei_default == 0);
+//
+// /* Add the AVLN and configure it as our AVLN. */
+// net = cp_sta_mgr_add_avln (&cp, 1, 1);
+// cp_sta_mgr_set_our_avln (&cp, net);
+//
+// /* Create some stations. */
+// for (i = 1; i < nbsta; i++)
+// {
+// /* Add the station in the station manager and at the same time in
+// * the mac store. */
+// sta = cp_sta_mgr_sta_add (&cp, net, i, i);
+// slab_release (sta);
+// }
+//
+// cp_sta_mgr_elects_sta_partial_ack (&cp);
+// test_fail_unless (mac_config.partial_ack_tei_default == 0);
+//
+// /* Ends the test. */
+// cp_sta_mgr_set_our_avln (&cp, NULL);
+//
+// mac_store_uninit (cp.mac_store);
+// cp_sta_mgr_uninit (&cp);
+// }
+// test_end;
}
void