From 8b7b9c9e0a3f0a2f2c5ff4d516a640002b5f1891 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Sat, 8 May 2021 13:38:43 +0200 Subject: [PATCH] Add scenarios tool --- .gitignore | 1 + Makefile | 11 +++++-- inputs.json | 28 +---------------- src/scenarios.cc | 82 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+), 30 deletions(-) create mode 100644 src/scenarios.cc diff --git a/.gitignore b/.gitignore index 41ed29e..c96c007 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ libs/simgrid libs/rapidjson compile_commands.json platform.xml +scenarios diff --git a/Makefile b/Makefile index b754389..3ed792d 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,19 @@ EXEC := simulator LIBS := ./libs/simgrid/build/lib INCLUDES := ./libs/simgrid/build/include ./libs/simgrid/include libs/rapidjson/include -CC := g++ -lsimgrid $(addprefix -L , $(LIBS)) $(addprefix -I , $(INCLUDES)) +SCENARIOS := src/scenarios.cc +CC := g++ $(addprefix -L , $(LIBS)) $(addprefix -I , $(INCLUDES)) +all: $(EXEC) $(basename $(notdir $(SCENARIOS))) -$(EXEC): $(wildcard src/*) +$(EXEC): $(filter-out $(SCENARIOS), $(wildcard src/*)) + $(CC) -lsimgrid $^ -o $@ + +$(basename $(notdir $(SCENARIOS))): $(SCENARIOS) $(CC) $^ -o $@ run: $(EXEC) export LD_LIBRARY_PATH=$(addprefix :, $(LIBS)) && ./$(EXEC) 10 --cfg=network/bandwidth-factor:1.05 --cfg=network/model:CM02 -–cfg=network/crosstraffic:0 clean: - -rm $(EXEC) \ No newline at end of file + -rm $(EXEC) $(basename $(notdir $(SCENARIOS))) \ No newline at end of file diff --git a/inputs.json b/inputs.json index 9fda5e6..757cea0 100644 --- a/inputs.json +++ b/inputs.json @@ -1,27 +1 @@ -{ - "extended":true, - "nodes":{ - "on0":{ - "is_sender": true, - "power_off": 0, - "power_on": 1, - "power_rx": 2, - "power_tx": 3, - "use_hint": true, - "wake_ts": [ 1, 7, 7 ], - "wake_duration": [ 5, 1, 2], - "data_size": 50 - }, - "on1":{ - "is_sender": false, - "power_off": 0, - "power_on": 10, - "power_tx": 10, - "power_rx": 10, - "use_hint": false, - "wake_ts": [ 1, 7, 8 ], - "wake_duration": [ 5, 5, 1], - "data_size": 50 - } - } -} +{"extended":false,"nodes":{"on0":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":true,"data_size":50,"wake_ts":[8.0,18.0,28.0,38.0,48.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0]},"on1":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":false,"data_size":50,"wake_ts":[5.0,15.0,25.0,35.0,45.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0]},"on2":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":false,"data_size":50,"wake_ts":[0.0,10.0,20.0,30.0,40.0,50.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0,5.0]},"on3":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":false,"data_size":50,"wake_ts":[1.0,11.0,21.0,31.0,41.0,51.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0,5.0]},"on4":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":false,"data_size":50,"wake_ts":[2.0,12.0,22.0,32.0,42.0,52.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0,5.0]},"on5":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":false,"data_size":50,"wake_ts":[4.0,14.0,24.0,34.0,44.0,54.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0,5.0]},"on6":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":false,"data_size":50,"wake_ts":[0.0,10.0,20.0,30.0,40.0,50.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0,5.0]},"on7":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":false,"data_size":50,"wake_ts":[0.0,10.0,20.0,30.0,40.0,50.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0,5.0]},"on8":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":false,"data_size":50,"wake_ts":[3.0,13.0,23.0,33.0,43.0,53.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0,5.0]},"on9":{"use_hint":false,"power_off":0,"power_on":10,"power_rx":11,"power_tx":12,"is_sender":false,"data_size":50,"wake_ts":[4.0,14.0,24.0,34.0,44.0,54.0],"wake_duration":[5.0,5.0,5.0,5.0,5.0,5.0]}}} \ No newline at end of file diff --git a/src/scenarios.cc b/src/scenarios.cc new file mode 100644 index 0000000..7f6185f --- /dev/null +++ b/src/scenarios.cc @@ -0,0 +1,82 @@ +#include +#include +#include + +#include +#include +#include +#include + + +#define RAND(min,max) (rand()%(max-min)+min) + +using namespace std; +using namespace rapidjson; + +#define N_NODE 10 +#define EXTENDED false +#define SIMULATION_DURATION 60 +#define POWER_OFF 0 +#define POWER_ON 10 +#define POWER_RX 11 +#define POWER_TX 12 +#define DATA_SIZE 50 +#define USE_HINT false +#define WAKE_UP_EVERY 10 +#define WAKE_UP_FOR 5 +#define MAX_STARTUP_DELAY 10 + +unsigned int seed = 0; + +int main(int argc, char **argv){ + // Setup seed + if(argc>1){ + srand( atoi(argv[1]) ); + } + + // Create document + Document d; + d.SetObject(); + d.AddMember("extended",EXTENDED,d.GetAllocator()); + + // Create nodes + Value nodes(kObjectType); + for(int i=0;i writer(buffer); + d.Accept(writer); + cout << buffer.GetString(); + + return 0; +} \ No newline at end of file