Routing Primitive

Routing Primitive#

From the previous example, we already have a 3-slice topology consisting of 4 nodes. This example demonstrates how to add time-flow entries to switches to enable network routing. For simplicity, we implement direct routing by adding time-flow entries only to nodes 0 and 1. The detailed definition of the time-flow entry can be found in the Path and Time Flow Table.

examples/routing_add_entry.py#
 1from openoptics import Toolbox
 2from openoptics.TimeFlowTable import TimeFlowHop, TimeFlowEntry
 3
 4if __name__ == "__main__":
 5    nb_node = 4
 6    net = Toolbox.BaseNetwork(
 7        name="add_entry",
 8        backend="Mininet",
 9        nb_node=nb_node,
10        time_slice_duration_ms=256,  # in ms
11        use_webserver=True,
12    )
13    net.connect(node1=0, node2=1, time_slice=0)
14    net.connect(node1=2, node2=3, time_slice=0)
15    net.connect(node1=0, node2=2, time_slice=1)
16    net.connect(node1=1, node2=3, time_slice=1)
17    net.connect(node1=0, node2=3, time_slice=2)
18    net.connect(node1=1, node2=2, time_slice=2)
19    net.deploy_topo()
20    node0_entries = []
21    node1_entries = []
22    node0_entries = [
23        TimeFlowEntry(
24            dst=1, arrival_ts=0, hops=[TimeFlowHop(cur_node=0, send_ts=0, send_port=0)]
25        ),
26        TimeFlowEntry(
27            dst=1, arrival_ts=1, hops=[TimeFlowHop(cur_node=0, send_ts=0, send_port=0)]
28        ),
29        TimeFlowEntry(
30            dst=1, arrival_ts=2, hops=[TimeFlowHop(cur_node=0, send_ts=0, send_port=0)]
31        ),
32    ]
33    node1_entries = [
34        TimeFlowEntry(
35            dst=0, arrival_ts=0, hops=[TimeFlowHop(cur_node=1, send_ts=0, send_port=0)]
36        ),
37        TimeFlowEntry(
38            dst=0, arrival_ts=1, hops=[TimeFlowHop(cur_node=1, send_ts=0, send_port=0)]
39        ),
40        TimeFlowEntry(
41            dst=0, arrival_ts=2, hops=[TimeFlowHop(cur_node=1, send_ts=0, send_port=0)]
42        ),
43    ]
44    net.add_time_flow_entry(node_id=0, entries=node0_entries, routing_mode="Source")
45    net.add_time_flow_entry(node_id=1, entries=node1_entries, routing_mode="Source")
46    net.start()