-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMain.py
More file actions
40 lines (28 loc) · 890 Bytes
/
Copy pathMain.py
File metadata and controls
40 lines (28 loc) · 890 Bytes
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
from Topology import Topology
from Scheduler import Scheduler
from AS import AS
from Interpreter import Interpreter
from Engine import Engine
import configparser
import time
import random
def generate_random_prefix():
subnet = random.randint(1, 32)
ip_int = random.getrandbits(32)
mask = (0xFFFFFFFF << (32 - subnet)) & 0xFFFFFFFF
network_int = ip_int & mask
octets = [
(network_int >> 24) & 0xFF,
(network_int >> 16) & 0xFF,
(network_int >> 8) & 0xFF,
network_int & 0xFF
]
return ".".join(map(str, octets)) + "/" + str(subnet)
if __name__ == "__main__":
config = configparser.ConfigParser()
config.read("config.ini")
topology = Topology()
interpreter = Interpreter()
interpreter.loadRoutingInformation(config, topology)
engine = Engine(config)
engine.run(config, topology)