-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimLoRaNetworkLite.py
62 lines (42 loc) · 1.47 KB
/
simLoRaNetworkLite.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
60
61
62
from multiprocessing import Pool
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from src.models.LoRaNetworkLite import LoRaNetworkLite
def get_simdata(v):
runs = 10
simTime = 912
numOCW = 7
numOBW = 280
numGrids = 8
granularity = 6
numFragments = 31
familyname = "driver"
CR = 2
nodes = int(v)
simulation = LoRaNetworkLite(simTime, familyname, numGrids, numOCW,
numOBW, nodes, numFragments, CR, granularity)
#decoded = simulation.run(runs)
occupancy = simulation.total_collided_slots(runs)
return occupancy # np.mean(occupancy)
if __name__ == "__main__":
netSizes = np.logspace(1.0, 4.0, num=50)
print('driver\tCR = 2')
pool = Pool(processes = len(netSizes))
result = pool.map(get_simdata, netSizes)
pool.close()
pool.join()
#print('avg_decoded_payloads\n', [round(i[0],6) for i in result])
#print('avg_decoded_packets\n', [round(i[1],6) for i in result])
print('total_collided_slots\n', [round(i,6) for i in result])
"""
transmissions = simulation.get_collision_matrix()
plt.figure(figsize=(18,12))
sns.heatmap(transmissions[0])
plt.title('transmissions using 1 OCW channel')
plt.xlabel(f'slots (w granularity={granularity})')
plt.ylabel('OBW')
plt.show()
#plt.savefig('transmissions-driver.png')
plt.close('all')
"""