summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
authorjelisavcic2009-09-14 07:41:27 +0000
committerjelisavcic2009-09-14 07:41:27 +0000
commit234a9b402adc365abb9138ef2d04570ce3c4e20f (patch)
treec7439c7e49c947873dbca19fa6316fea514036b6 /cesar
parentb7f1c863b4773d4c6cf8222e653796360b42b9ee (diff)
[CESAR][TEST_GENERAL][INTEGRATION][PBPROC][EOC]
Test suite for SOF/RSOF, ticket #480. * Tested two stations. * Test 3 or more stations. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@5533 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar')
-rw-r--r--cesar/test_general/maximus/integration/sar-pbproc-eoc/Config3
-rw-r--r--cesar/test_general/maximus/integration/sar-pbproc-eoc/Makefile13
-rw-r--r--cesar/test_general/maximus/integration/sar-pbproc-eoc/doc/test1.txt76
-rw-r--r--cesar/test_general/maximus/integration/sar-pbproc-eoc/ecos.ecc.sh5
-rw-r--r--cesar/test_general/maximus/integration/sar-pbproc-eoc/src/station.c1166
-rw-r--r--cesar/test_general/maximus/integration/sar-pbproc-eoc/test1.py128
-rw-r--r--cesar/test_general/maximus/integration/sar-pbproc-eoc/test2.py100
-rw-r--r--cesar/test_general/maximus/integration/sar-pbproc-eoc/test3.py138
8 files changed, 1629 insertions, 0 deletions
diff --git a/cesar/test_general/maximus/integration/sar-pbproc-eoc/Config b/cesar/test_general/maximus/integration/sar-pbproc-eoc/Config
new file mode 100644
index 0000000000..2c5fd00047
--- /dev/null
+++ b/cesar/test_general/maximus/integration/sar-pbproc-eoc/Config
@@ -0,0 +1,3 @@
+CONFIG_MAC_COMMON_EOC_SCHED = y
+CONFIG_PBPROC_FC_EOC = y
+CONFIG_TRACE = y
diff --git a/cesar/test_general/maximus/integration/sar-pbproc-eoc/Makefile b/cesar/test_general/maximus/integration/sar-pbproc-eoc/Makefile
new file mode 100644
index 0000000000..35857aa023
--- /dev/null
+++ b/cesar/test_general/maximus/integration/sar-pbproc-eoc/Makefile
@@ -0,0 +1,13 @@
+BASE = ../../../..
+
+ECOS = y
+
+INCLUDES = test_general/station/overide/ \
+
+TARGET_PROGRAMS = sar-pbproc
+
+sar-pbproc_SOURCES = station.c
+sar-pbproc_MODULES = hal/phy/maximus \
+ lib mac host
+
+include $(BASE)/common/make/top.mk
diff --git a/cesar/test_general/maximus/integration/sar-pbproc-eoc/doc/test1.txt b/cesar/test_general/maximus/integration/sar-pbproc-eoc/doc/test1.txt
new file mode 100644
index 0000000000..8c4a02df01
--- /dev/null
+++ b/cesar/test_general/maximus/integration/sar-pbproc-eoc/doc/test1.txt
@@ -0,0 +1,76 @@
+= SAR - PBproc =
+
+This tests :
+ * The Tx transmission
+ * The Rx reception.
+
+This test is done with two stations (Station1 and Station2).
+
+== Test configuration ==
+
+The stations shall be configured first before launching the test :
+ * Snid, tei, CA shedules.
+ * Links in the Mac Store.
+ * Data buffers for the SAR.
+
+== Function Calls ==
+
+=== fc_station_init_config ===
+
+To configure the station.
+
+Parameters :
+ * snid : The snid of the station.
+ * tei : the station tei.
+ * auto_sched : To create automatically the schedules for the CA.
+
+=== fc_station_link_add ===
+
+Add a link to the station i.e. create a MFS in the mac store.
+
+Parameters :
+ * type : TX/RX MFS.
+ * bcast : Broadcast MFS
+ * mme : MME MFS.
+ * lid : The lid of the MFS.
+ * tei : The source/destination station.
+
+
+=== fc_sar_data_buffer_add ===
+
+Add a data buffer for the SAR to reassembly some Mac Frames.
+
+=== fc_sar_msdu_add ===
+
+Request the SAR to segment and send a MSDU.
+
+Parameters :
+ * tei : Station destination TEI.
+ * lid : Link identifier.
+ * bcast : broadcast link.
+ * mme : MME MFS (if setted, it will not use the lid value).
+ * length : The msdu length.
+ * buffer : The data to segment.
+
+=== fc_station_link_remove ===
+
+Remove a link from the station (and from the mac store).
+
+Parameters :
+ * type : TX/RX MFS.
+ * bcast : Broadcast MFS
+ * mme : MME MFS.
+ * lid : The lid of the MFS.
+ * tei : The source/destination station.
+
+=== fc_sar_print_trace ===
+
+To print the SAR traces taken during the test.
+To see the SAR traces add a Config file to the make directory with the
+following line.
+
+{{{
+CONFIG_TRACE=y
+}}}
+
+And compile again the test.
diff --git a/cesar/test_general/maximus/integration/sar-pbproc-eoc/ecos.ecc.sh b/cesar/test_general/maximus/integration/sar-pbproc-eoc/ecos.ecc.sh
new file mode 100644
index 0000000000..7984aef8ed
--- /dev/null
+++ b/cesar/test_general/maximus/integration/sar-pbproc-eoc/ecos.ecc.sh
@@ -0,0 +1,5 @@
+config=${1:-ecos-gen.ecc}
+ecosconfig --config=$config new maximus default
+cat >> $config <<EOF
+EOF
+ecosconfig --config=$config check
diff --git a/cesar/test_general/maximus/integration/sar-pbproc-eoc/src/station.c b/cesar/test_general/maximus/integration/sar-pbproc-eoc/src/station.c
new file mode 100644
index 0000000000..1fd5be5688
--- /dev/null
+++ b/cesar/test_general/maximus/integration/sar-pbproc-eoc/src/station.c
@@ -0,0 +1,1166 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file test_general/integration/interface-dp/src/station.c
+ * \brief Station interface - DP.
+ * \ingroup test_general
+ *
+ * Test the integration of the interface with the data plane.
+ * The sniffer will be added to this test later.
+ */
+#include <cyg/kernel/kapi.h>
+#include <cyg/hal/hal_arch.h>
+
+#include "common/std.h"
+#include "mac/common/timings.h"
+#include "host/station/station.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+/** Library include. */
+#include "lib/read_word.h"
+#include "lib/trace.h"
+#include "lib/circular_buffer.h"
+#include "lib/list.h"
+
+/** Data include. */
+#include "mac/common/config.h"
+#include "mac/common/ntb.h"
+#include "mac/common/store.h"
+
+/** Layers include. */
+#include "mac/sar/sar.h"
+#include "mac/pbproc/pbproc.h"
+#include "mac/ca/ca.h"
+#include "mac/pbproc/inc/context.h"
+#include "mac/ca/inc/context.h"
+
+#include "mac/sar/inc/trace.h"
+#include "lib/rnd.h"
+
+struct tei_node_t
+{
+ list_node_t node;
+ uint tei;
+};
+typedef struct tei_node_t tei_node_t;
+
+
+/** station context. */
+struct station_test_t
+{
+ /** The mac config. */
+ mac_config_t mac_config;
+ /** Short network identifier. */
+ u8 snid;
+ /** The mac store. */
+ mac_store_t *mac_store;
+
+ // Layers
+ /** Pbproc context. */
+ pbproc_t *pbproc;
+ /** Sar context. */
+ sar_t *sar;
+
+ /* Schedule index. */
+ uint sched_index;
+ /* Pbproc activate. */
+ bool pbproc_activate;
+
+ cyg_handle_t sched_handle;
+ cyg_thread sched_thread;
+
+ /** Used to memorize the list of TEI inserted in the mac_Store to remove it
+ * in the future.
+ */
+ list_t tei_list;
+ /** create schedule only on CCo side */
+ bool create_schedule;
+ /** beacon alloc type: 0 csma only,1 mixed csma & tdma */
+ uint beacon_alloc_type;
+};
+typedef struct station_test_t station_test_t;
+
+
+u8 mme_buffer [2048] __attribute__((aligned (2048)));
+u8 sched_stack [CYGNUM_HAL_STACK_SIZE_TYPICAL];
+
+//----------------------------------------------------------------------------
+
+static station_test_t station_test;
+
+/****************** CALL BACKS DEFINITION ****************/
+
+/**
+ * Call back called by the SAR each time a packet is segmented.
+ * In this test it will only display a message.
+ * The buffer is a static buffer not a allocated one it does not need to be
+ * freed.
+ *
+ * \param user, User data
+ * \param buffer the address of the buffer.
+ */
+void sar_segmentation_ul_done (void *user, u8* buffer, void *cl_data)
+{
+ printf ("******************************************\n");
+ printf (" sar Segmentation done\n \n");
+ printf ("******************************************\n");
+}
+
+/**
+ * Implementation of the sar_reassembly_done_cb_t call back.
+ * Only used in this test.
+ * The buffer and the mfs shall be release.
+ *
+ * \param user, User data
+ * \param buffer the buffer address containing the data
+ * \param length the data length
+ * \param mfs the mfs used
+ */
+void sar_reassembly_ul_done (void *user, u8* buffer, uint length,
+ mfs_rx_t *mfs, bool encrypted)
+{
+ dbg_assert (buffer);
+ dbg_assert (length >= 60 && length <= 1518);
+ dbg_assert (mfs);
+
+ printf ("******************************************\n");
+ printf (" sar Reassembly done\n \n");
+ printf ("******************************************\n");
+
+ free (buffer);
+
+ blk_print_memory ();
+}
+
+/**
+ * Implementation of the sar_reassembly_done_cb_t call back.
+ * Only used in this test.
+ * The buffer and the mfs shall be release.
+ *
+ * \param user, User data
+ * \param buffer the buffer address containing the data
+ * \param length the data length
+ * \param mfs the mfs used
+ */
+void sar_reassembly_mme_done (void *user, u8* buffer, uint length,
+ mfs_rx_t *mfs, bool encrypted)
+{
+ dbg_assert (buffer);
+ dbg_assert (length >= 60 && length <= 1518);
+ dbg_assert (mfs);
+
+ printf ("******************************************\n");
+ printf (" sar Reassembly MME done\n");
+ printf ("******************************************\n");
+
+ sar_mme_buffer_add (station_test.sar, buffer);
+
+ blk_print_memory ();
+}
+
+// ---------------------------- Station functions --------------------------
+
+/**
+ * Add a link to the STAtion i.e. will create a MFS
+ *
+ * \param ctx the station context.
+ * \param type TX or RX link, it is a short 1 for TX 0 for RX.
+ * \param bcast short indicating if the link is a broadcast link
+ * \param mme short indicating if the link will be use to transmit MMEs
+ * \param lid short indicating if it is a link identitier.
+ * \param tei short the destination station.
+ */
+void station_test_link_add (station_test_t *ctx, uint type, uint bcast,
+ uint mme, uint lid, uint tei)
+{
+ bool added;
+ mfs_t *mfs;
+ sta_t *sta;
+
+ dbg_assert (ctx);
+ dbg_assert (ctx->mac_store);
+ dbg_assert (ctx->sar);
+
+ if (MAC_TEI_IS_STA (tei))
+ {
+ mac_store_sta_add (ctx->mac_store, tei);
+ sta = mac_store_sta_get (ctx->mac_store, tei);
+ sta->authenticated = true;
+ blk_release (sta);
+ }
+
+ mfs = mac_store_mfs_add (ctx->mac_store, type, bcast, mme, lid, tei,
+ &added);
+ dbg_assert (added);
+
+ // add the link to the sar.
+ sar_mfs_add (ctx->sar, mfs);
+
+ /* Authenticated the station. */
+
+ blk_release (mfs);
+}
+
+/**
+ * Remove a link to the STAtion i.e. will create a MFS
+ *
+ * \param ctx the station context.
+ * \param type TX or RX link, it is a short 1 for TX 0 for RX.
+ * \param bcast short indicating if the link is a broadcast link
+ * \param mme short indicating if the link will be use to transmit MMEs
+ * \param lid short indicating if it is a link identitier.
+ * \param tei short the destination station.
+ */
+void station_test_link_remove (station_test_t *ctx, uint type, uint bcast,
+ uint mme, uint lid, uint tei)
+{
+ /*
+ mfs_t *mfs;
+ pb_t *pb;
+ */
+
+ dbg_assert (ctx);
+ dbg_assert (ctx->mac_store);
+ dbg_assert (ctx->sar);
+ dbg_assert (MAC_TEI_IS_STA (tei));
+
+ sar_sta_remove (ctx->sar, tei);
+
+ /*
+ mfs = mac_store_mfs_get (ctx->mac_store, type, bcast, mme, lid, tei);
+
+ if (mfs != NULL)
+ {
+ while (type && mfs->tx.head)
+ {
+ pb = mfs->tx.head;
+ mfs->tx.head = mfs->tx.head->next;
+ blk_release_desc ((blk_t *) pb);
+ }
+
+ while (!type && mfs->rx.head)
+ {
+ pb = mfs->rx.head;
+ mfs->rx.head = mfs->rx.head->next;
+ blk_release_desc ((blk_t *) pb);
+ }
+
+ // remove the MFS from the sar
+ sar_mfs_remove (ctx->sar, mfs);
+
+ blk_release (mfs);
+ }
+ */
+}
+
+/* creation of false scheduling */
+void
+test_prepare_tdma_alloc_random(pbproc_t *ctx, uint max_length_tck)
+{
+ lib_rnd_t rnd[1];
+ lib_rnd_init (rnd, 1234);
+ ca_eoc_sched_t * alloc = &ctx->ca->ca_eoc_sched;
+ alloc->record_nb = 1 + lib_rnd_uniform (rnd, 20);
+ alloc->record_curr = 0;
+ uint i;
+ uint fixed_clk = MAC_RIFS_DEFAULT_TCK
+ + MAC_PREAMBLE_TCK + 2 * MAC_FC_AV_TCK;
+ for (i=0; i < alloc->record_nb; i++)
+ {
+ alloc->sched_record[i].tei = lib_rnd_uniform (rnd, 10)
+ + 3;
+ alloc->sched_record[i].lid = lib_rnd_uniform (rnd, MAC_PLID_NB);
+// + MAC_PLID_MIN;
+ alloc->sched_record[i].cco_tx_duration = fixed_clk
+ + MAC_PAYLOAD_TCK (20+lib_rnd_uniform (rnd, 20),
+ MAC_DX417_TCK);
+ alloc->sched_record[i].sta_tx_duration = fixed_clk
+ + MAC_PAYLOAD_TCK (20+lib_rnd_uniform (rnd, 20),
+ MAC_DX417_TCK);
+ }
+}
+
+
+/**
+ * Create a schedule for the Channel Access (beacon period) in CSMA only mode.
+ * Shall always be used to send or receive data.
+ *
+ * \param int_sta the pbproc context
+ * \param beacon_period_nb the quantity of beacon periods for the test.
+ */
+void create_schedule_csma_only (station_test_t *int_sta, uint beacon_period_nb)
+{
+ pbproc_t *pbproc;
+
+ dbg_assert (int_sta);
+
+ pbproc = int_sta->pbproc;
+ ca_beacon_period_t beacons_periods[beacon_period_nb];
+ uint i;
+
+ dbg_assert (pbproc);
+ dbg_assert (beacon_period_nb < CA_BEACON_PERIOD_NB);
+
+ /* Get and fill the schedule */
+ ca_schedule_t *sched = ca_alloc_get_schedule (pbproc_get_ca (pbproc),
+ int_sta->sched_index);
+
+ sched->coexistence_mode = MAC_COEXISTENCE_SHARED_CSMA_HYBRID_MODE;
+ sched->snid = int_sta->snid;
+ sched->nek_switch = 0; //TODO
+ sched->allocations_nb = 1;
+ sched->allocations[0].end_offset_tck = 10000000;
+ sched->allocations[0].glid = 0xff;
+
+ /* Create a schedule for 14 beacon period */
+ for (i = 0; i < beacon_period_nb; i++)
+ {
+ beacons_periods[i].start_date = 1000000 * i
+ + my_station.current_tick_tck;
+ beacons_periods[i].schedule_index = int_sta->sched_index;
+ }
+
+ /* Use the new schedule */
+ ca_alloc_update_beacon_periods (pbproc_get_ca (pbproc), beacons_periods,
+ beacon_period_nb);
+
+ /* Activate the pbproc */
+ if (!int_sta->pbproc_activate)
+ {
+ pbproc_activate (pbproc, true);
+ int_sta->pbproc_activate = true;
+ }
+
+ int_sta->sched_index++;
+}
+
+void create_schedule_mixed_csma_tdma(station_test_t *int_sta,
+ uint beacon_period_nb)
+{
+ pbproc_t *pbproc;
+
+ dbg_assert (int_sta);
+
+ pbproc = int_sta->pbproc;
+ ca_beacon_period_t beacons_periods[beacon_period_nb];
+ uint i;
+
+ dbg_assert (pbproc);
+ dbg_assert (beacon_period_nb < CA_BEACON_PERIOD_NB);
+
+ /* Get and fill the schedule */
+ ca_schedule_t *sched = ca_alloc_get_schedule (pbproc_get_ca (pbproc),
+ int_sta->sched_index);
+
+ sched->coexistence_mode = MAC_COEXISTENCE_SHARED_CSMA_HYBRID_MODE;
+ sched->snid = int_sta->snid;
+ sched->nek_switch = 0; //TODO
+ /* create scheduling only on CCo side. */
+ sched->allocations_nb = 3;
+ sched->allocations[0].end_offset_tck = 100000;
+ sched->allocations[0].glid = MAC_LID_SPC_CENTRAL;
+ sched->allocations[1].end_offset_tck = 800000;
+ sched->allocations[1].glid = MAC_LID_CFPI;
+ sched->allocations[2].end_offset_tck = 1000000;
+ sched->allocations[2].glid = MAC_LID_LOCAL_CSMA;
+
+ /* Create a schedule for 14 beacon period */
+ for (i = 0; i < beacon_period_nb; i++)
+ {
+ beacons_periods[i].start_date = 1000000 * i
+ + my_station.current_tick_tck;
+ beacons_periods[i].schedule_index = int_sta->sched_index;
+ }
+
+ /* Use the new schedule */
+ ca_alloc_update_beacon_periods (pbproc_get_ca (pbproc), beacons_periods,
+ beacon_period_nb);
+
+ /* Activate the pbproc */
+ if (!int_sta->pbproc_activate)
+ {
+ pbproc_activate (pbproc, true);
+ int_sta->pbproc_activate = true;
+ }
+
+ int_sta->sched_index++;
+}
+
+/**
+ * Thread entry finction
+ *
+ * \param int_sta the sta context.
+ */
+void pbproc_sched (cyg_addrword_t int_sta)
+{
+ printf ("[STATION_THR] Start \n");
+
+ station_test_t *station_test;
+
+ station_test = (station_test_t *) int_sta;
+ while (true)
+ {
+ printf ("[STATION_THR] Working \n");
+ switch (station_test->beacon_alloc_type)
+ {
+ case 0:
+ create_schedule_csma_only (station_test, 14);
+ station_test->sched_index ++;
+ //create the second schedule.
+ create_schedule_csma_only (station_test, 14);
+ station_test->sched_index ++;
+ //create the third schedule.
+ create_schedule_csma_only (station_test, 14);
+ station_test->sched_index ++;
+ break;
+ case 1:
+ create_schedule_mixed_csma_tdma (station_test, 14);
+ station_test->sched_index ++;
+ //create the second schedule.
+ create_schedule_mixed_csma_tdma (station_test, 14);
+ station_test->sched_index ++;
+ //create the third schedule.
+ create_schedule_mixed_csma_tdma (station_test, 14);
+ station_test->sched_index ++;
+ }
+ cyg_thread_delay (500);
+ }
+}
+
+
+/**
+ * Provides the Tei of the STA and the SNID
+ *
+ * \param ctx the station context
+ * \param tei the tei of the station
+ * \param snid the snid of the AVLN
+ * \param beacon_period_auto generation automatic of the beacon period for
+ * the CA scheduling
+ * \param cco boolean informing if the sta is cco or not
+ * \param authenticated boolean informing if the sta is authenticated or
+ * not.
+ */
+void station_test_config (station_test_t *ctx, uint tei, uint snid,
+ bool beacon_period_auto, mac_t mac_addr)
+{
+ dbg_assert (ctx);
+
+ ctx->snid = snid;
+ ctx->mac_config.tei = tei;
+ ctx->create_schedule = MAC_TEI_IS_EOC_CCO(ctx->mac_config.tei);
+
+ if (mac_addr == 0)
+ {
+ ctx->mac_config.sta_mac_address = 0x123456789abcull;
+ }
+ else
+ ctx->mac_config.sta_mac_address = mac_addr;
+
+ if (ctx->create_schedule)
+ test_prepare_tdma_alloc_random(ctx->pbproc, 100000);
+
+ if (beacon_period_auto)
+ {
+ // Create the Thread for the pbproc.
+ cyg_thread_create (9, &pbproc_sched, (cyg_addrword_t) ctx, "Sched",
+ sched_stack, CYGNUM_HAL_STACK_SIZE_TYPICAL,
+ &ctx->sched_handle, &ctx->sched_thread);
+ cyg_thread_resume (ctx->sched_handle);
+
+ printf ("[STATION] PBproc Activated\n");
+ }
+
+ sar_mme_buffer_add (ctx->sar, mme_buffer);
+ sar_activate (ctx->sar, true);
+}
+
+/**
+ * Provides the TEI of all the station in the AVLN.
+ *
+ * \param ctx the station context.
+ * \param tei the tei list of the stations
+ * \param qte the quantity of TEIs in the list.
+ */
+void station_test_discover (station_test_t *ctx, uint *tei,
+ uint qte)
+{
+ tei_node_t *node;
+ uint i;
+
+ for (i = 0; i < qte; i++)
+ {
+ if (tei[i] != 0)
+ {
+ node = blk_alloc ();
+ list_init_node (&node->node);
+ node->tei = tei[i];
+ list_push (&ctx->tei_list, &node->node);
+
+ mac_store_sta_add (ctx->mac_store, tei[i]);
+ }
+ }
+}
+
+
+// ---------------------------- Function calls -----------------------------
+
+/** Uninitialise the function
+ */
+int fc_station_uninit (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data)
+{
+ uint i;
+ sar_activate (station_test.sar, false);
+ pbproc_activate (station_test.pbproc, false);
+
+ for (i = MAC_TEI_STA_MIN; MAC_TEI_IS_STA (i); i++)
+ sar_sta_remove (station_test.sar, i);
+
+ sar_uninit (station_test.sar);
+ pbproc_uninit (station_test.pbproc);
+ mac_store_uninit (station_test.mac_store);
+
+ blk_print_memory ();
+
+ return true;
+}
+
+/** Creates a link in the STA.
+ *
+ * - dtei the tei of the station.
+ * - fw forward link
+ * - rw reverse link
+ * - bcast broadcast.
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_add_mme_link (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data)
+{
+ uint dtei = 0;
+ uint fw = 0;
+ uint rw = 0;
+ uint bcast = 0;
+
+ mfs_tx_t *mfs_tx;
+ mfs_rx_t *mfs_rx;
+ bool added;
+
+ fcall_param_bind_short (*param, *msg, "dtei", &dtei);
+ fcall_param_bind_short (*param, *msg, "fw", &fw);
+ fcall_param_bind_short (*param, *msg, "rw", &rw);
+ fcall_param_bind_short (*param, *msg, "bcast", &bcast);
+
+ fcall_param_reset (*param);
+
+ if (fw)
+ {
+ mfs_tx = mac_store_mfs_add_tx (station_test.mac_store, bcast, true, MAC_LID_NONE, dtei, &added);
+
+ if (mfs_tx == NULL)
+ return false;
+
+ sar_mfs_add (station_test.sar, (mfs_t *) mfs_tx);
+ blk_release (mfs_tx);
+ }
+
+ if (rw)
+ {
+ mfs_rx = mac_store_mfs_add_rx (station_test.mac_store, bcast, true, MAC_LID_NONE, dtei, &added);
+
+ if (mfs_rx == NULL)
+ return false;
+
+ sar_mfs_add (station_test.sar, (mfs_t *) mfs_rx);
+ blk_release (mfs_rx);
+ }
+
+ return true;
+}
+
+/** Initialise the station parameters data as the mac address the tei.
+ *
+ * - stei.
+ * - mac_addr.
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_station_config (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data)
+{
+ uint stei = 0;
+ mac_t mac_address = 0;
+
+ fcall_param_bind_short (*param, *msg, "stei", &stei);
+ fcall_param_bind (*param, *msg, "mac_addr", sizeof(mac_t), &mac_address);
+
+ station_test.mac_config.sta_mac_address = mac_address;
+ station_test.mac_config.tei = stei;
+ station_test.mac_config.authenticated = true;
+ sar_activate (station_test.sar, true);
+
+ fcall_param_reset (*param);
+
+ return true;
+}
+
+int fc_station_config_bt (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data)
+{
+ uint beacon_alloc_type=0;
+
+ fcall_param_bind_short (*param, *msg, "beacon_alloc_type",
+ &beacon_alloc_type);
+
+ station_test.beacon_alloc_type = beacon_alloc_type;
+
+ fcall_param_reset (*param);
+
+ return true;
+}
+
+/** Prepare the station to work.
+ * It will create default schedules for the Channel Access in CSMA-only mode
+ * and activate the pbproc to start the communication with the others
+ * stations.
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_station_start (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data)
+{
+ ca_beacon_period_t beacons_periods[4];
+ uint i;
+
+ /* Get and fill the schedule */
+ ca_schedule_t *sched = ca_alloc_get_schedule (pbproc_get_ca (station_test.pbproc),0);
+
+ sched->coexistence_mode = MAC_COEXISTENCE_SHARED_CSMA_HYBRID_MODE;
+ sched->snid = station_test.snid;
+ sched->nek_switch = 0; //TODO
+ sched->allocations_nb = 1;
+ sched->allocations[0].end_offset_tck = BITS_ONES (24);
+ sched->allocations[0].glid = 0xff;
+
+ /* Create a schedule for 14 beacon period */
+ for (i = 0; i < 4; i++)
+ {
+ beacons_periods[i].start_date = BITS_ONES(24) * i
+ + my_station.current_tick_tck;
+ beacons_periods[i].schedule_index = 0;
+ }
+
+ /* Use the new schedule */
+ ca_alloc_update_beacon_periods (pbproc_get_ca (station_test.pbproc), beacons_periods,
+ 4);
+
+ /* Only run this one !!! */
+ pbproc_activate (station_test.pbproc, true);
+
+ return true;
+}
+
+/**
+ * Add a link to the Station in order to receive or transmit data.
+ *
+ * - type TX or RX link, it is a short 1 for TX 0 for RX.
+ * - bcast short indicating if the link is a broadcast link
+ * - mme short indicating if the link will be use to transmit MMEs
+ * - lid short indicating if it is a link identitier.
+ * - tei short the destination station.
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_station_link_add (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data)
+{
+ uint type;
+ uint bcast;
+ uint mme;
+ uint lid;
+ uint tei;
+
+ type = 0;
+ bcast = 0;
+ mme = 0;
+ lid = 0;
+ tei = 0;
+
+ fcall_param_bind_short (*param, *msg, "type", &type);
+ fcall_param_bind_short (*param, *msg, "bcast", &bcast);
+ fcall_param_bind_short (*param, *msg, "mme", &mme);
+ fcall_param_bind_short (*param, *msg, "lid", &lid);
+ fcall_param_bind_short (*param, *msg, "tei", &tei);
+
+ if (type)
+ printf (
+ "[STATION : %d] TX link added, bcast : %d, mme : %d, lid : %d, tei : %d\n",
+ station_test.mac_config.tei, bcast, mme, lid, tei);
+ else
+ printf (
+ "[STATION : %d] RX link added, bcast : %d, mme : %d, lid : %d, tei : %d\n",
+ station_test.mac_config.tei, bcast, mme, lid, tei);
+
+ if (!mme)
+ station_test_link_add (&station_test, 0, bcast, mme, lid, tei);
+ station_test_link_add (&station_test, 1, bcast, mme, lid, tei);
+
+ fcall_param_reset (*param);
+
+ return true;
+}
+
+/**
+ * Remove a link to the Station in order to receive or transmit data.
+ *
+ * - type TX or RX link, it is a short 1 for TX 0 for RX.
+ * - bcast short indicating if the link is a broadcast link
+ * - mme short indicating if the link will be use to transmit MMEs
+ * - lid short indicating if it is a link identitier.
+ * - tei short the destination station.
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_station_link_remove (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data)
+{
+ uint type;
+ uint bcast;
+ uint mme;
+ uint lid;
+ uint tei;
+
+ type = 0;
+ bcast = 0;
+ mme = 0;
+ lid = 0;
+ tei = 0;
+
+ fcall_param_bind_short (*param, *msg, "type", &type);
+ fcall_param_bind_short (*param, *msg, "bcast", &bcast);
+ fcall_param_bind_short (*param, *msg, "mme", &mme);
+ fcall_param_bind_short (*param, *msg, "lid", &lid);
+ fcall_param_bind_short (*param, *msg, "tei", &tei);
+
+ if (type)
+ printf (
+ "[STATION : %d] TX link removed, bcast : %d, mme : %d, lid : %d, tei : %d\n",
+ station_test.mac_config.tei, bcast, mme, lid, tei);
+ else
+ printf (
+ "[STATION : %d] RX link removed, bcast : %d, mme : %d, lid : %d, tei : %d\n",
+ station_test.mac_config.tei, bcast, mme, lid, tei);
+
+ station_test_link_remove (&station_test, 0, bcast, mme, lid, tei);
+ station_test_link_remove (&station_test, 1, bcast, mme, lid, tei);
+
+ fcall_param_reset (*param);
+
+ return true;
+}
+
+/**
+ * Initialize the configuration of the STA.
+ * The parameters we must provide are the TEI of the STA, the SNID and the
+ * boolean to indicate the auto generation of the beacon periods.
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_station_init_config (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data)
+{
+ uint tei;
+ uint snid;
+ uint beacon_period_auto;
+ mac_t mac;
+
+ tei = 0;
+ snid = 0;
+ beacon_period_auto = 0;
+
+ fcall_param_bind_short (*param, *msg, "tei", &tei);
+ fcall_param_bind_short (*param, *msg, "snid", &snid);
+ fcall_param_bind_short (*param, *msg, "auto_sched", &beacon_period_auto);
+
+ station_test_config (&station_test, tei, snid, beacon_period_auto, mac);
+
+ fcall_param_reset (*param);
+
+ return true;
+}
+
+int fc_station_init_config_bt (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data)
+{
+ uint beacon_alloc_type=0;
+
+ fcall_param_bind_short (*param, *msg, "beacon_alloc_type",
+ &beacon_alloc_type);
+
+ station_test.beacon_alloc_type = beacon_alloc_type;
+
+ fcall_param_reset (*param);
+
+ return true;
+}
+
+/**
+ * Add a data buffer to the SAR.
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_sar_data_buffer_add (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data)
+{
+ u8 *buffer;
+
+ buffer = (u8*) malloc (2048 * sizeof(u8));
+ sar_data_buffer_add (station_test.sar, buffer);
+
+ fcall_param_reset (*param);
+
+ return true;
+}
+
+/**
+ * Add Msdu to send
+ *
+ * - lid the link to use
+ * - tei the destination
+ * - bcast if the link is a bcast link
+ * - mme if it is a mme
+ * - buffer the buffer containing a frame
+ * - length the buffer length
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_sar_msdu_add (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data)
+{
+ uint tei;
+ uint lid;
+ uint bcast;
+ uint mme;
+ uint length;
+ u8 *buffer;
+
+ mfs_tx_t *mfs;
+
+ tei = 0;
+ lid = 0;
+ bcast = 0;
+ mme = 0;
+ length = 0;
+
+ fcall_param_bind_short (*param, *msg, "tei", &tei);
+ fcall_param_bind_short (*param, *msg, "lid", &lid);
+ fcall_param_bind_short (*param, *msg, "bcast", &bcast);
+ fcall_param_bind_short (*param, *msg, "mme", &mme);
+ fcall_param_bind_short (*param, *msg, "length", &length);
+
+ buffer = (u8 *) malloc (length * sizeof (length));
+ fcall_param_bind (*param, *msg, "buffer", length * sizeof(u8), buffer);
+
+ mfs = mac_store_mfs_get_tx (station_test.mac_store, bcast, mme, lid, tei);
+ dbg_assert (mfs);
+
+ sar_msdu_add (station_test.sar, buffer, length, mfs, NULL,
+ mac_ntb());
+
+ blk_release (mfs);
+
+ fcall_param_reset (*param);
+
+ return true;
+}
+
+/**
+ * Provide to the STA using the parameters of the function call the station
+ * use for the test. Each STA shall known the TEI of the others present in the
+ * AVLN.
+ *
+ * The function call parameters must be
+ * - qte the quantity of TEIs present in the paramters. One for each STA
+ * without this one.
+ * - tei The list of TEIs.
+ * - mac the list of mac address.
+ *
+ * This will be use to add the STA's to the mac store, the STA will keep a
+ * list of theses TEI to remove the STA during the uninit procedure.
+ *
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_station_discover (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data)
+{
+ uint tei[256];
+ mac_t macs[256];
+ uint qte;
+ char val [2];
+ char id[5];
+ uint count;
+ uint error;
+
+ qte = 0;
+ fcall_param_bind_short (*param, *msg, "qte", &qte);
+
+ count = 0;
+ error = 0;
+ for (count = 0; count < qte; count ++)
+ {
+ tei[count] = 0;
+ macs[count] = 0;
+ sprintf (val, "%d", count);
+ strcpy (id, "tei");
+ strcat (id, val);
+ fcall_param_bind_short (*param, *msg, id, &tei[count]);
+ }
+
+ station_test_discover (&station_test, tei, qte);
+
+ fcall_param_reset (*param);
+
+ return true;
+}
+
+/**
+ * print the sar traces for the tests.
+ * if the trace_config == y the traces are printed to the stdio.
+ * otherwise nothing is printed.
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_sar_print_trace (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data)
+{
+ fcall_param_reset (*param);
+
+ sar_trace_print (station_test.sar);
+ /* trace_buffer_dbg_dump (&station_test.pbproc->trace);
+ trace_buffer_dbg_dump (&station_test.pbproc->ca->trace); */
+
+ return true;
+}
+
+
+// ---------------------------- Stub functions ----------------------------
+
+/**
+ * CE measurements. To be replace by the CE function to get the measurements
+ *
+ * Pb measurement RX callback for Channel estimation.
+ * This call back will return one or two block in order to insert all the
+ * measurements contained in each PB of the mpdu received.
+ * Two cases can happen, the first the pb_nb is lesser than the blk capacity,
+ * this callback will return only a blk pointed by the first and the last
+ * pointer.
+ * In the second case the quantity of PB are greater than one blk capacity, this
+ * callback will return two blk (chained) the first pointed by the first pointer
+ * and the last one by the last pointer.
+ *
+ * \param user User data
+ * \param rx_params Frame control information to know date and tonemap used
+ * \param number of pbs
+ * \param first blk to insert the measurements.
+ * \param last blk to insert the measurements.
+ * \param chandata chan data measurements
+ *
+ * \return boolean to indicate if a block had been returned or not.
+ */
+bool ce_measurements (void *user, pbproc_rx_params_t *rx_params, uint pb_nb,
+ blk_t **first, blk_t **last, pb_t *chandata, uint nb_chandata, uint
+ *blk_offset)
+{
+ dbg_assert (rx_params);
+
+ if (chandata)
+ {
+ blk_release_desc_range_nb ((blk_t *) chandata, nb_chandata);
+ }
+
+ return false;
+}
+
+
+/**
+* CP receives a new MME.
+* \param user_data the data registered by the actor in the init function.
+* \param mfs the mfs
+* \param buffer the buffer containing the MME.
+* \param length the MME length
+* \param mme_recv data use by the data plane.
+* \param encryption inform if the packet comes from the PWL if it had been
+* crypted or not.
+*/
+void
+cp_mme_recv (void *user_data, mfs_rx_t *mfs, u8 *buffer, uint length,
+ bool mme_recv, bool encryption)
+{
+ printf ("/*************************************************/\n");
+ printf ("/ STATION : %d Receive a MME **********/\n",
+ station_test.mac_config.tei);
+ printf ("/ MME length : %d **********/\n", length);
+ printf ("/ MME encrypted : %d **********/\n",
+ encryption);
+ printf ("/*************************************************/\n");
+}
+
+/**
+* CP receives a beacon.
+* \param user_data the data registered by the actor in the init function.
+* \param beacon the beacon freshly received.
+*/
+void
+cp_beacon_add (void *user_data, pb_beacon_t *beacon)
+{
+ printf ("/*************************************************/\n");
+ printf ("/ STATION : %d Receive a beacon ********/\n",
+ station_test.mac_config.tei);
+ printf ("/*************************************************/\n");
+
+
+ // release the beacon.
+ blk_release_desc ((blk_t *) beacon);
+}
+
+// -------------------------------------------------------------------------
+
+
+/** Cesar init function as described in the wiki
+ * http://pessac/cesar/trac/wiki/20071128Cesar#LEONcore
+ */
+void
+cesar_init (void)
+{
+ // Initialise the trace system.
+ trace_init ();
+
+ // Initialise the mac_store.
+ station_test.mac_store = mac_store_init ();
+
+ // Initialise the mac config.
+ mac_config_init (&station_test.mac_config);
+
+ // Intialise the pbproc.
+ station_test.pbproc = pbproc_init (&station_test.mac_config,
+ station_test.mac_store);
+
+ // Initialise the mac ntb.
+ mac_ntb_init (pbproc_get_phy(station_test.pbproc), &station_test.mac_config);
+
+ // Initialise the SAR.
+ station_test.sar = sar_init (station_test.mac_store, station_test.pbproc,
+ pbproc_get_ca (station_test.pbproc),
+ station_test.mac_config.seed);
+
+ // init the variables of the station.
+ station_test.pbproc_activate = false;
+ station_test.sched_index = 0;
+}
+
+
+/* ---------------------- Main function -------------------*/
+int
+cyg_user_start (void)
+{
+ cesar_init ();
+
+ station_log_set_level(&my_station, STATION_LOG_DEBUG);
+ my_station.pipe_log_fd = 1;
+
+ fcall_register (my_station.fcall, "fc_station_link_add",
+ &fc_station_link_add, NULL);
+
+ fcall_register (my_station.fcall, "fc_station_link_remove",
+ &fc_station_link_remove, NULL);
+
+ fcall_register (my_station.fcall, "fc_station_init_config",
+ &fc_station_init_config, NULL);
+
+ fcall_register (my_station.fcall, "fc_station_config_bt",
+ &fc_station_config_bt, NULL);
+
+ fcall_register (my_station.fcall, "fc_sar_data_buffer_add",
+ &fc_sar_data_buffer_add, NULL);
+
+ fcall_register (my_station.fcall, "fc_sar_mme_buffer_add",
+ &fc_sar_data_buffer_add, NULL);
+
+ fcall_register (my_station.fcall, "fc_sar_msdu_add", &fc_sar_msdu_add,
+ NULL);
+
+ fcall_register (my_station.fcall, "fc_station_discover",
+ &fc_station_discover, NULL);
+
+ fcall_register (my_station.fcall, "fc_add_mme_link",
+ &fc_add_mme_link , NULL);
+
+ fcall_register (my_station.fcall, "fc_station_config",
+ &fc_station_config, NULL);
+
+ fcall_register (my_station.fcall, "fc_station_start",
+ &fc_station_start, NULL);
+
+ fcall_register (my_station.fcall, "fc_sar_print_trace",
+ &fc_sar_print_trace, NULL);
+
+ fcall_register (my_station.fcall, "fc_station_uninit",
+ &fc_station_uninit, NULL);
+
+ sar_init_data_context (station_test.sar, station_test.sar);
+ sar_init_mme_context (station_test.sar, station_test.sar);
+
+ sar_init_segmentation_data_cb (station_test.sar, sar_segmentation_ul_done);
+ sar_init_segmentation_mme_cb (station_test.sar, sar_segmentation_ul_done);
+ sar_init_reassembly_data_cb (station_test.sar, sar_reassembly_ul_done);
+ sar_init_reassembly_mme_cb (station_test.sar, sar_reassembly_mme_done);
+
+ sar_init_measure_context (station_test.sar, &station_test.sar);
+ sar_init_measurement_cb (station_test.sar, ce_measurements);
+
+ return 0;
+}
+
+void test_print_trace(void)
+{
+ sar_trace_print (station_test.sar);
+ trace_buffer_dbg_dump (&station_test.pbproc->trace);
+ trace_buffer_dbg_dump (&station_test.pbproc->ca->trace);
+}
diff --git a/cesar/test_general/maximus/integration/sar-pbproc-eoc/test1.py b/cesar/test_general/maximus/integration/sar-pbproc-eoc/test1.py
new file mode 100644
index 0000000000..b035a588d2
--- /dev/null
+++ b/cesar/test_general/maximus/integration/sar-pbproc-eoc/test1.py
@@ -0,0 +1,128 @@
+#!/usr/bin/env python
+
+import sys
+sys.path.append('../../../../maximus/python/obj');
+
+from interface import *
+from string import *
+from struct import *
+
+maximus = Maximus()
+maximus.init (sys.argv + ['-e', './obj/sar-pbproc.elf'])
+
+# TEI of station 1 will be 1
+station1 = maximus.create_sta()
+#station1.debug()
+
+# TEI of station 2 will be 5
+station2 = maximus.create_sta()
+#station2.debug()
+
+fc1 = maximus.create_fcall ("fc_station_init_config")
+fc1.set_sta (station1)
+fc1.add_param_ushort ("snid", 1)
+fc1.add_param_ushort ("tei", 1)
+fc1.add_param_ushort ("auto_sched", 1)
+fc1.send()
+
+fc2 = maximus.create_fcall ("fc_station_init_config")
+fc2.set_sta (station2)
+fc2.add_param_ushort ("snid", 1)
+fc2.add_param_ushort ("tei", 5)
+fc2.add_param_ushort ("auto_sched", 1)
+fc2.send()
+
+fc1 = maximus.create_fcall ("fc_station_link_add")
+fc1.set_sta (station1)
+fc1.add_param_ushort ("type", 1)
+fc1.add_param_ushort ("bcast", 0)
+fc1.add_param_ushort ("mme", 0)
+fc1.add_param_ushort ("lid", 1)
+fc1.add_param_ushort ("tei", 5)
+fc1.send()
+
+fc2 = maximus.create_fcall ("fc_station_link_add")
+fc2.set_sta (station2)
+fc2.add_param_ushort ("type", 0)
+fc2.add_param_ushort ("bcast", 0)
+fc2.add_param_ushort ("mme", 0)
+fc2.add_param_ushort ("lid", 1)
+fc2.add_param_ushort ("tei", 1)
+fc2.send()
+
+fc2 = maximus.create_fcall ("fc_sar_data_buffer_add")
+fc2.set_sta (station2)
+fc2.send()
+
+fc2 = maximus.create_fcall ("fc_sar_data_buffer_add")
+fc2.set_sta (station2)
+fc2.send()
+
+fc1 = maximus.create_fcall ("fc_sar_msdu_add")
+fc1.set_sta (station1)
+fc1.add_param_ushort ("tei", 5)
+fc1.add_param_ushort ("lid", 1)
+fc1.add_param_ushort ("bcast", 0)
+fc1.add_param_ushort ("mme", 0)
+fc1.add_param_ushort ("length", 106)
+f = open ('../../packet1','r')
+fc1.add_param ("buffer", f.read())
+fc1.send()
+
+
+maximus.wait (1000)
+fc1 = maximus.create_fcall ("fc_sar_msdu_add")
+fc1.set_sta (station1)
+fc1.add_param_ushort ("tei", 5)
+fc1.add_param_ushort ("lid", 1)
+fc1.add_param_ushort ("bcast", 0)
+fc1.add_param_ushort ("mme", 0)
+fc1.add_param_ushort ("length", 106)
+f = open ('../../packet1','r')
+fc1.add_param ("buffer", f.read())
+fc1.send()
+
+maximus.wait (10000000)
+
+fc1 = maximus.create_fcall ("fc_station_link_remove")
+fc1.set_sta (station1)
+fc1.add_param_ushort ("type", 1)
+fc1.add_param_ushort ("bcast", 0)
+fc1.add_param_ushort ("mme", 0)
+fc1.add_param_ushort ("lid", 1)
+fc1.add_param_ushort ("tei", 5)
+fc1.send()
+
+fc2 = maximus.create_fcall ("fc_station_link_remove")
+fc2.set_sta (station2)
+fc2.add_param_ushort ("type", 0)
+fc2.add_param_ushort ("bcast", 0)
+fc2.add_param_ushort ("mme", 0)
+fc2.add_param_ushort ("lid", 1)
+fc2.add_param_ushort ("tei", 1)
+fc2.send()
+
+maximus.wait(10000)
+
+print "\n************ STATION 1 TRACE ***************\n"
+fc1 = maximus.create_fcall ("fc_sar_print_trace")
+fc1.set_sta(station1)
+fc1.send();
+
+fc1 = maximus.create_fcall ("fc_station_uninit")
+fc1.set_sta(station1)
+fc1.send();
+
+station1.remove()
+
+
+print "\n************ STATION 2 TRACE ***************\n"
+fc1 = maximus.create_fcall ("fc_sar_print_trace")
+fc1.set_sta(station2)
+fc1.send();
+
+fc1 = maximus.create_fcall ("fc_station_uninit")
+fc1.set_sta(station2)
+fc1.send();
+
+station2.remove()
diff --git a/cesar/test_general/maximus/integration/sar-pbproc-eoc/test2.py b/cesar/test_general/maximus/integration/sar-pbproc-eoc/test2.py
new file mode 100644
index 0000000000..db204117e8
--- /dev/null
+++ b/cesar/test_general/maximus/integration/sar-pbproc-eoc/test2.py
@@ -0,0 +1,100 @@
+#!/usr/bin/env python
+
+import sys
+sys.path.append('../../../../maximus/python/obj');
+
+from interface import *
+from string import *
+from struct import *
+
+maximus = Maximus()
+maximus.init (sys.argv + ['-e', './obj/sar-pbproc.elf'])
+
+# TEI of station 1 will be 1
+station1 = maximus.create_sta()
+#station1.debug()
+
+# TEI of station 2 will be 2
+station2 = maximus.create_sta()
+#station2.debug()
+
+fc1 = maximus.create_fcall ("fc_station_init_config")
+fc1.set_sta (station1)
+fc1.add_param_ushort ("snid", 1)
+fc1.add_param_ushort ("tei", 1)
+fc1.add_param_ushort ("auto_sched", 1)
+fc1.send()
+
+fc2 = maximus.create_fcall ("fc_station_init_config")
+fc2.set_sta (station2)
+fc2.add_param_ushort ("snid", 1)
+fc2.add_param_ushort ("tei", 5)
+fc2.add_param_ushort ("auto_sched", 1)
+fc2.send()
+
+fc1 = maximus.create_fcall ("fc_station_link_add")
+fc1.set_sta (station1)
+fc1.add_param_ushort ("type", 1)
+fc1.add_param_ushort ("bcast", 1)
+fc1.add_param_ushort ("mme", 1)
+fc1.add_param_ushort ("lid", 248)
+fc1.add_param_ushort ("tei", 255)
+fc1.send()
+
+fc1 = maximus.create_fcall ("fc_sar_msdu_add")
+fc1.set_sta (station1)
+fc1.add_param_ushort ("tei", 255)
+fc1.add_param_ushort ("lid", 248)
+fc1.add_param_ushort ("bcast", 1)
+fc1.add_param_ushort ("mme", 1)
+fc1.add_param_ushort ("length", 106)
+f = open ('../../packet1','r')
+fc1.add_param ("buffer", f.read())
+fc1.send()
+
+
+maximus.wait (1000)
+fc1 = maximus.create_fcall ("fc_sar_msdu_add")
+fc1.set_sta (station1)
+fc1.add_param_ushort ("tei", 255)
+fc1.add_param_ushort ("lid", 248)
+fc1.add_param_ushort ("bcast", 1)
+fc1.add_param_ushort ("mme", 1)
+fc1.add_param_ushort ("length", 106)
+f = open ('../../packet1','r')
+fc1.add_param ("buffer", f.read())
+fc1.send()
+
+maximus.wait (10000000)
+
+fc2 = maximus.create_fcall ("fc_station_link_remove")
+fc2.set_sta (station2)
+fc2.add_param_ushort ("type", 0)
+fc2.add_param_ushort ("bcast", 1)
+fc2.add_param_ushort ("mme", 1)
+fc2.add_param_ushort ("lid", 248)
+fc2.add_param_ushort ("tei", 1)
+fc2.send()
+
+print "\n************ STATION 1 TRACE ***************\n"
+fc1 = maximus.create_fcall ("fc_sar_print_trace")
+fc1.set_sta(station1)
+fc1.send();
+
+fc1 = maximus.create_fcall ("fc_station_uninit")
+fc1.set_sta(station1)
+fc1.send();
+
+station1.remove()
+
+
+print "\n************ STATION 2 TRACE ***************\n"
+fc1 = maximus.create_fcall ("fc_sar_print_trace")
+fc1.set_sta(station2)
+fc1.send();
+
+fc1 = maximus.create_fcall ("fc_station_uninit")
+fc1.set_sta(station2)
+fc1.send();
+
+station2.remove()
diff --git a/cesar/test_general/maximus/integration/sar-pbproc-eoc/test3.py b/cesar/test_general/maximus/integration/sar-pbproc-eoc/test3.py
new file mode 100644
index 0000000000..7566f79864
--- /dev/null
+++ b/cesar/test_general/maximus/integration/sar-pbproc-eoc/test3.py
@@ -0,0 +1,138 @@
+#!/usr/bin/env python
+
+import sys
+sys.path.append('../../../../maximus/python/obj');
+
+from interface import *
+from string import *
+from struct import *
+
+maximus = Maximus()
+maximus.init (sys.argv + ['-e', './obj/sar-pbproc.elf'])
+
+# TEI of station 1 will be 1
+station1 = maximus.create_sta()
+#station1.debug()
+
+# TEI of station 2 will be 5
+station2 = maximus.create_sta()
+#station2.debug()
+
+fc1 = maximus.create_fcall ("fc_station_config_bt")
+fc1.set_sta (station1)
+fc1.add_param_ushort ("beacon_alloc_type", 1)
+fc1.send()
+
+fc1 = maximus.create_fcall ("fc_station_init_config")
+fc1.set_sta (station1)
+fc1.add_param_ushort ("snid", 1)
+fc1.add_param_ushort ("tei", 1)
+fc1.add_param_ushort ("auto_sched", 1)
+fc1.send()
+
+fc2 = maximus.create_fcall ("fc_station_config_bt")
+fc2.set_sta (station1)
+fc2.add_param_ushort ("beacon_alloc_type", 1)
+fc2.send()
+
+fc2 = maximus.create_fcall ("fc_station_init_config")
+fc2.set_sta (station2)
+fc2.add_param_ushort ("snid", 1)
+fc2.add_param_ushort ("tei", 5)
+fc2.add_param_ushort ("auto_sched", 1)
+fc2.send()
+
+fc1 = maximus.create_fcall ("fc_station_link_add")
+fc1.set_sta (station1)
+fc1.add_param_ushort ("type", 1)
+fc1.add_param_ushort ("bcast", 0)
+fc1.add_param_ushort ("mme", 0)
+fc1.add_param_ushort ("lid", 1)
+fc1.add_param_ushort ("tei", 5)
+fc1.send()
+
+fc2 = maximus.create_fcall ("fc_station_link_add")
+fc2.set_sta (station2)
+fc2.add_param_ushort ("type", 0)
+fc2.add_param_ushort ("bcast", 0)
+fc2.add_param_ushort ("mme", 0)
+fc2.add_param_ushort ("lid", 1)
+fc2.add_param_ushort ("tei", 1)
+fc2.send()
+
+fc2 = maximus.create_fcall ("fc_sar_data_buffer_add")
+fc2.set_sta (station2)
+fc2.send()
+
+fc2 = maximus.create_fcall ("fc_sar_data_buffer_add")
+fc2.set_sta (station2)
+fc2.send()
+
+fc1 = maximus.create_fcall ("fc_sar_msdu_add")
+fc1.set_sta (station1)
+fc1.add_param_ushort ("tei", 5)
+fc1.add_param_ushort ("lid", 1)
+fc1.add_param_ushort ("bcast", 0)
+fc1.add_param_ushort ("mme", 0)
+fc1.add_param_ushort ("length", 106)
+f = open ('../../packet1','r')
+fc1.add_param ("buffer", f.read())
+fc1.send()
+
+maximus.wait (10000)
+
+fc1 = maximus.create_fcall ("fc_sar_msdu_add")
+fc1.set_sta (station1)
+fc1.add_param_ushort ("tei", 5)
+fc1.add_param_ushort ("lid", 1)
+fc1.add_param_ushort ("bcast", 0)
+fc1.add_param_ushort ("mme", 0)
+fc1.add_param_ushort ("length", 106)
+f = open ('../../packet1','r')
+fc1.add_param ("buffer", f.read())
+fc1.send()
+
+maximus.wait (10000000)
+
+fc1 = maximus.create_fcall ("fc_station_link_remove")
+fc1.set_sta (station1)
+fc1.add_param_ushort ("type", 1)
+fc1.add_param_ushort ("bcast", 0)
+fc1.add_param_ushort ("mme", 0)
+fc1.add_param_ushort ("lid", 1)
+fc1.add_param_ushort ("tei", 5)
+fc1.send()
+
+fc2 = maximus.create_fcall ("fc_station_link_remove")
+fc2.set_sta (station2)
+fc2.add_param_ushort ("type", 0)
+fc2.add_param_ushort ("bcast", 0)
+fc2.add_param_ushort ("mme", 0)
+fc2.add_param_ushort ("lid", 1)
+fc2.add_param_ushort ("tei", 1)
+fc2.send()
+
+maximus.wait(10000)
+
+print "\n************ STATION 1 TRACE ***************\n"
+fc1 = maximus.create_fcall ("fc_sar_print_trace")
+fc1.set_sta(station1)
+fc1.send();
+
+fc1 = maximus.create_fcall ("fc_station_uninit")
+fc1.set_sta(station1)
+fc1.send();
+
+station1.remove()
+
+
+print "\n************ STATION 2 TRACE ***************\n"
+fc1 = maximus.create_fcall ("fc_sar_print_trace")
+fc1.set_sta(station2)
+fc1.send();
+
+fc1 = maximus.create_fcall ("fc_station_uninit")
+fc1.set_sta(station2)
+fc1.send();
+
+station2.remove()