Skip to content

Commit

Permalink
Fix ns-3-ra example segfault on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
m-wojnar committed Aug 11, 2024
1 parent 8faf087 commit af7b980
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ pip install reinforced-lib
```

To have easy access to the [example files](https://github.com/m-wojnar/reinforced-lib/tree/main/examples)
you can clone the source code from our repository, and than install it locally with pip:
you can clone the source code from our repository, and then install it locally with pip:

```bash
git clone git@github.com:m-wojnar/reinforced-lib.git
cd reinforced-lib
pip install .
pip install -e .
```

In the spirit of making Reinforced-lib a lightweight solution, we include only the necessary dependencies in the base
Expand Down
2 changes: 1 addition & 1 deletion examples/ns-3-ccod/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def run(
else:
rl = RLib.load(rlib_args['load_path'])

exp = Experiment(mempool_key, memory_size, simulation, ns3_path, debug=False)
exp = Experiment(mempool_key, memory_size, simulation, ns3_path, using_waf=False)
var = Ns3AIRL(memblock_key, Env, Act)

try:
Expand Down
2 changes: 2 additions & 0 deletions examples/ns-3-ccod/scratch/ccod-sim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,8 @@ main (int argc, char *argv[])
}

Simulator::Destroy();
m_env->SetFinish ();

cout << "Packets registered by handler: " << g_rxPktNum << " Packets" << endl;

return 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#include "ns3/string.h"
#include "ns3/double.h"
#include "ns3/log.h"
#include "rlib-wifi-manager.h"
#include "ns3/rlib-wifi-manager.h"
#include "ns3/wifi-phy.h"
#include "ns3/wifi-tx-vector.h"
#include "ns3/wifi-utils.h"

#define Min(a,b) ((a < b) ? a : b)
#define DEFAULT_MEMBLOCK_KEY 2333

namespace ns3 {

NS_LOG_COMPONENT_DEFINE ("RLibWifiManager");
Expand Down Expand Up @@ -50,8 +47,6 @@ RLibWifiManager::RLibWifiManager ()
{
NS_LOG_FUNCTION (this);

// Setup ns3-ai Env
m_env = new Ns3AIRL<sEnv, sAct> (DEFAULT_MEMBLOCK_KEY);
m_env->SetCond (2, 0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "ns3/wifi-remote-station-manager.h"
#include "ns3/ns3-ai-module.h"

#define DEFAULT_MEMBLOCK_KEY 2333

namespace ns3 {

// ns3-ai structures
Expand All @@ -25,6 +27,8 @@ struct sAct
uint8_t mcs;
} Packed;

Ns3AIRL<sEnv, sAct> * m_env = new Ns3AIRL<sEnv, sAct> (DEFAULT_MEMBLOCK_KEY);

// Structure holding additional information required by the RLibWifiManager
struct RLibWifiRemoteStation : public WifiRemoteStation
{
Expand Down Expand Up @@ -64,8 +68,6 @@ class RLibWifiManager : public WifiRemoteStationManager
uint32_t m_nWifi;
uint32_t m_nss;
double m_power;

Ns3AIRL<sEnv, sAct> * m_env;
};

}
Expand Down
2 changes: 1 addition & 1 deletion examples/ns-3-ra/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def run(
ext_type=IEEE_802_11_ax_RA
)

exp = Experiment(mempool_key, memory_size, simulation, ns3_path)
exp = Experiment(mempool_key, memory_size, simulation, ns3_path, using_waf=False)
var = Ns3AIRL(memblock_key, Env, Act)

try:
Expand Down
2 changes: 2 additions & 0 deletions examples/ns-3-ra/scratch/ra-sim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "ns3/ssid.h"
#include "ns3/wifi-net-device.h"
#include "ns3/yans-wifi-helper.h"
#include "ns3/rlib-wifi-manager.h"

using namespace ns3;

Expand Down Expand Up @@ -412,6 +413,7 @@ main (int argc, char *argv[])

//Clean-up
Simulator::Destroy ();
m_env->SetFinish ();

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions examples/ns-3-ra/tools/slurm/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
NS3_DIR="${NS3_DIR:=$HOME/ns-3.37}"

cd $NS3_DIR
./ns3 configure -d optimized --disable-python
./ns3
./ns3 configure --build-profile=optimized --disable-examples --disable-tests
./ns3 build

0 comments on commit af7b980

Please sign in to comment.