-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerateMessage_random.py
More file actions
59 lines (34 loc) · 1.21 KB
/
generateMessage_random.py
File metadata and controls
59 lines (34 loc) · 1.21 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
54
55
56
57
from constants import *
import random
num_gen = 5
for i in range(num_gen):
message_file = open("Generated_Messages/generated_messages" + str(i) + ".txt", "w")
message_file.write("ID\ts\td\tTTL\tsize\tgenT\n")
min_burst = 5
max_burst = 20
min_wait = 5
max_wait = 15
t = 0
msg_count = 0
small = [60, 600]
large = [1500, 3000]
while t < T - TTL:
# print(t)
num_msg_to_gen = random.randint(min_burst, max_burst)
time_to_next_burst = random.randint(min_wait, max_wait)
for i in range(num_msg_to_gen):
p = random.randint(0,100)
if p < 80:
size = random.choice(small)
else:
size = random.choice(large)
src = random.randint(0, NoOfSources - 1)
dst = random.randint(NoOfSources, NoOfSources + NoOfDataCenters - 1)
genT = t
desired_TTL = random.randint(minTTL, TTL)
line = str(msg_count) + "\t" + str(src) + "\t" + str(dst) + "\t" + str(TTL) + "\t" \
+ str(size) + "\t" + str(t) + "\n"
message_file.write(line)
msg_count += 1
t += time_to_next_burst
message_file.close()