forked from gh0st42/PONS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sim.py
59 lines (45 loc) · 1.16 KB
/
sim.py
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
54
55
56
57
58
59
import random
import json
# import cProfile
import pons
import pons.routing
RANDOM_SEED = 42
# SIM_TIME = 3600*24*7
SIM_TIME = 3600 * 24
NET_RANGE = 50
NUM_NODES = 10
WORLD_SIZE = (1000, 1000)
CAPACITY = 10000
# CAPACITY = 0
# 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
)
net = pons.NetworkSettings("WIFI_50m", range=NET_RANGE)
epidemic = pons.routing.EpidemicRouter(capacity=CAPACITY)
nodes = pons.generate_nodes(NUM_NODES, net=[net], router=epidemic)
config = {"movement_logger": False, "peers_logger": False, "event_logging": False}
msggenconfig = {
"type": "single",
"interval": 30,
"src": (0, NUM_NODES),
"dst": (0, NUM_NODES),
"size": 100,
"id": "M",
"ttl": 3600,
}
netsim = pons.NetSim(
SIM_TIME,
nodes,
world_size=WORLD_SIZE,
movements=moves,
config=config,
msggens=[msggenconfig],
)
netsim.setup()
# cProfile.run("netsim.run()")
netsim.run()
print(json.dumps(netsim.net_stats, indent=4))
print(json.dumps(netsim.routing_stats, indent=4))