forked from gh0st42/PONS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsim_two_net.py
More file actions
53 lines (40 loc) · 1.57 KB
/
Copy pathsim_two_net.py
File metadata and controls
53 lines (40 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import random
import json
import pons
import pons.routing
from math import floor, ceil
RANDOM_SEED = 42
SIM_TIME = 3600
NET_RANGE1 = 50
NET_RANGE2 = 100
NUM_NODES = 15
WORLD_SIZE = (1000, 1000)
# Setup and start the simulation
print('Python Opportunistic Network Simulator')
random.seed(RANDOM_SEED)
moves = pons.generate_randomwaypoint_movement(
SIM_TIME, NUM_NODES, WORLD_SIZE[0], WORLD_SIZE[1], max_pause=60.0)
net1 = pons.NetworkSettings("WIFI_SHORT", range=NET_RANGE1)
net2 = pons.NetworkSettings("WIFI_LONG", range=NET_RANGE2, loss=0.01)
epidemic = pons.routing.EpidemicRouter()
# first node group only part of net1
nodes1 = pons.generate_nodes(
int(floor(NUM_NODES/3)), net=[net1], router=epidemic)
# second node group only part of net2
nodes2 = pons.generate_nodes(
int(floor(NUM_NODES/3)), net=[net2], router=epidemic, offset=floor(NUM_NODES/3))
# third node group part of both networks
nodes3 = pons.generate_nodes(
int(ceil(NUM_NODES/3)), net=[net1, net2], router=epidemic, offset=floor(NUM_NODES/3)*2)
nodes = nodes1 + nodes2 + nodes3
config = {"movement_logger": False, "peers_logger": False}
msggenconfig = {"type": "single", "interval": 30, "src": (
0, NUM_NODES), "dst": (0, NUM_NODES), "size": 100, "id": "M"}
netsim = pons.NetSim(SIM_TIME, WORLD_SIZE, nodes, moves,
config=config, msggens=[msggenconfig])
netsim.setup()
# m = pons.Message("MSG1", 1, 2, 100, 0)
# pons.delayed_execution(netsim.env, 0, nodes[0].router.add(m))
netsim.run()
print(json.dumps(netsim.net_stats, indent=4))
print(json.dumps(netsim.routing_stats, indent=4))