From c2e6aad09f893e4c8cb5cb9243c32a0d6d0d1e12 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Thu, 9 Jun 2022 21:48:32 +0200 Subject: Init ESDS repository --- example/simulator.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 example/simulator.py (limited to 'example/simulator.py') diff --git a/example/simulator.py b/example/simulator.py new file mode 100755 index 0000000..9b00887 --- /dev/null +++ b/example/simulator.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python + +# Load ESDS +import sys +sys.path.append("../") +import esds + +# Use numpy to construct bandwidth and latencies matrix +import numpy as np + +##### Scenario +# The simulated scenario comprises 1 that wakes up randomly +# for a duration called "uptime" every hour. The sender try to transmit +# his data during that uptime. Other nodes are receivers that have similar +# random wake up parterns and strive to receive data from the sender. + +##### Bandwidth matrix +# Bandwidth value can be 0 for unreachable nodes +# Diagonal entries impact the transmission duration for wireless transmissions (wlan0) +n=2 # Number of nodes including the sender +B=np.full((n,n),5) # 5Mbps + +##### Latency matrix +# If the latency entries match one with a bandwidth of 0 +# then it will be ignore since node is unreachable. +L=np.full((n,n),0) # 0s + +##### Create the simulator +s=esds.Simulator(B,L) + +##### Instantiate nodes +uptime=180 # 180s uptime +s.create_node("sender",args=uptime) # Load sender.py for the first node with 5 as argument (first row in B and L) + +# Aguments can be passed to nodes via: s.create_node("sender",args="my argument") +for n in range(0,n-1): # Load receiver.py for the remaining nodes + s.create_node("receiver",args=uptime) + +##### Run the simulation +#s.run(debug=True) # Generate a "esds.debug" file +s.run() -- cgit v1.2.3