When we are implementing a fat-tree topology datacenter, we cannot use a simple learning switch to connect the network since simple switch does flooding for unknown destination thus in fat-tree there will be packets stuck in the loop. So we need to use openflow to program the controller to controll switching.
In this article, we first implement a simple example where a controller controlls packet switching in a 2-linear network like the figure below.
In this topology, when we do “h1 ping h2”, h1 first send ARP packet to s1 and s1 ask controller to get flow entries if it’s a simple learning switch and that’s not what we want. This time, we try to make it a dumb switch and when controller senses ARP message, it installs flow entry to s1 and s2 immediately so that there won’t be any flooding.
Psuedo Code:
|
|
Again we use mininet to simulate the network and use ryu to implement openflow controller.
First part is to read header of packet to examine whether it’s a ARP request. If so, we first add flow entries to switches then we send ARP response back.
|
|
In add_flow function, we use the dumb way to add 4 flow entries into 2 switches separately. Note that we need to implement a L3 layer switch for fat-tree data center. Thus we need to contain IP messages inside flow entries, not hardware addresss.
|
|
While sending ARP response, we need to compose an ARP packet by ourselves and write header and content of the packet properly.
|
|
The whole source code should look like this.
|
|