Software Defined Networking (SDN) - by A Harika
This is an article written by A Harika under her BTech Honors program (2016-18)
Workflow -


Fig. 2 . Creating topology and connecting to the ODL controller
Fig. 3 Querying the topology using postman (REST API CLIENT)

Fig. 4 Query Response in Json:
The main objective of SDN (Software defined networking) is to decouple the control plane from the data and consolidating the control logic of devices into dedicated centralized control. One can leverage the features of SDN in finding the shortest path for the dynamically changing topology by extracting the topology information from the SDN controller through rest API's. Therefore the virtual machine migration in data centers becomes resilient for dynamically changing topologies.
Workflow -

Fig .1 Starting ODL Controller

Fig. 2 . Creating topology and connecting to the ODL controller
Fig. 3 Querying the topology using postman (REST API CLIENT)
The Northbound API's of SDN controller can be used to query the topology information. In this regard, one can use POSTMAN (REST API CLIENT) for the same. The following GET Request was used in Postman http://192.168.56.1:8181/restconf/operational/network-topology:network-topology

Fig. 4 Query Response in Json:
link": [
{
"link-id": "openflow:1:2",
"destination": {
"dest-tp": "openflow:2:2",
"dest-node": "openflow:2"
},
"source": {
"source-node": "openflow:1",
"source-tp": "openflow:1:2"
}
},
{
"link-id": "openflow:2:2",
"destination": {
"dest-tp": "openflow:1:2",
"dest-node": "openflow:1"
},
"source": {
"source-node": "openflow:2",
"source-tp": "openflow:2:2"
}
},
{
"link-id": "openflow:4:2",
"destination": {
"dest-tp": "openflow:3:3",
"dest-node": "openflow:3"
},
"source": {
"source-node": "openflow:4",
"source-tp": "openflow:4:2"
}
]
By utilizing this topology information and a python module named NETWORKx a graph can be created in mininet with the nodes as the nodes in the topology and by using the link information edges can be created.
Python code to extract the topology information/creating the graph
import requests
import networkx as nx
url =" http://192.168.43.97:8181/restconf/operational/network-topology:network-topology"
r= requests.get(url.strip(),headers = {"Authorization":"Basic YWRtaW46YWRtaW4="})
#strip is used since url will be appended with \n
x=r.json()
edgelist = []
dest={}
src={}
t=()
nodeslist = []
for i in range(len(x['network-topology']['topology'][0]['link'])):
for key,val in x['network-topology']['topology'][0]['link'][i].items():
if 'destination' in key:
dest=val
for k,v in dest.items():
if 'dest-node' in k:
a=(v)
if 'source' in key:
src=val
for k,v in src.items():
if 'source-node' in k:
b=(v)
t=(a,b)
edgelist.append(t)
for j in range(len(x['network-topology']['topology'][0]['node'])):
for key,val in x['network-topology']['topology'][0]['node'][j].items():
if 'node-id' in key:
nodeslist.append(val)
G = nx.Graph()
G.add_edges_from(edgelist)
print "Nodes in the topology"
print nodeslist
print "Enter the list id for the source node(ID starts from zero)"
source = input()
print "Enter the Destination node id"
destination = input()
path = nx.dijkstra_path(G,nodeslist[source], nodeslist[destination])
print "shortest path is : "
print path
At this stage, it should be noted that by using the inbuilt library for Dijkstra's algorithm in the NETWORKx module onecan find the shortest path based on the hop count by giving source and destination nodes as the parameters. One can introduce changes in the topology by executing the commands like
link S1 S2 down/link s2 s3 up.When we run the code again REST API retrieves
the updated topology information and shortest path is found for the new topology/.
In this way SDN can be used to find the shortest path for the dynamically changing topologies in data centers by making use odf NorthboundAPI.
Comments
Post a Comment