SDN5
SDN5
• This script is provided by the course and it defines the structure and
parameters of the network. The network consists of four layers: core,
aggregation, edge, and host. Each layer has a number of switches and links
that connect them. The switches are OpenFlow- enabled and can be
controlled by POX.
• To run the script, you need to open a terminal and type: sudo
python clos topo.py
• This will create the network topology and start Mininet. You will see a
prompt like this: mininet>
• You can use various commands to interact with the network, such as
pingall, dump, nodes, etc. You can see a list of commands by typing
help.
• Step 2: Run the script CloudNetController.py to start the POX
controller that will manage the network
o This script is provided by the course and it contains the code
relating to the SDN applications that you will implement. The script
uses POX’s API to communicate with the switches and install flow
rules on them. The script also defines some helper functions and
classes that you will use in your tasks.
o To run the script, you need to open another terminal and type:
./pox.py log.level --DEBUG CloudNetController
o This will start POX and load the script. You will see some messages
like this: INFO:core:POX 0.5.0 (carp) is up.
o The controller will connect to the switches and send them some
initial flow rules. You will see some messages like
this: DEBUG:CloudNetController:Installing initial flow rules for switch
s1
• Step 3: Implement basic routing
are the source and destination switch names, respectively. It returns a list of switch names that form the
shortest path between them.
For example, if the shortest path from s1 to s4 is s1-s2-s4, the function returns [‘s1’, ‘s2’, ‘s4’].
• To use the get shortest path function, you need to map the
host names to switch names. You can use
the host to switch dictionary that is provided by the script. This dictionary maps each host name to its
connected switch name. For example, host_to_switch[‘h1’] returns ‘s1’.
• To write the function, you can follow these steps:
o Initialize an empty list called path.
o Get the switch name of the source host by using
the host to switch dictionary and store it in a variable called
src switch.
o Get the switch name of the destination host by using
the host to switch dictionary and store it in a variable called
dst switch.
o Call the get shortest path function
with src switch and dst switch as parameters and store the result in
a variable called switch path.
o Append src switch to path.
o Loop through switch path from index 1 to the end and
append each element to path.
o Append dst switch to path.
o Return path.
Step 4: Implement firewall policies to block traffic between certain hosts
or applications
o In this task, you need to write a function
called task2 firewall policies that takes three parameters: src, dst, and app, which are the source
host name, destination host name, and application name, respectively.
o The function should return a boolean value that indicates whether the
traffic should be blocked or not. For example, if there is a firewall policy
that blocks traffic from h1 to h2 for app1, the function should return
True when called with src=‘h1’, dst=‘h2’, and app=‘app1’.
o To implement the firewall policies, you can use
the firewall policies list that is provided by the script. This list contains tuples of three elements: source host
name, destination host name, and application name. Each tuple represents a firewall policy that blocks traffic
between those hosts for that application.
For example, (‘h1’, ‘h2’, ‘app1’) means that traffic from h1 to h2 for app1 is blocked.
To write the function, you can follow these steps:
•
o Initialize a variable called blocked with False.
o Loop through the firewall policies list and check if
there is a tuple that matches the parameters.
o If there is a match, set blocked to True and break out of the loop.
o Return blocked.
Step 5: Implement virtual network slicing to isolate different
tenants or applications
o In this task, you need to write a function
called task3 virtual network slicing that takes three parameters: src, dst, and app, which
are the source host name, destination host name, and application name, respectively.
o The function should return a boolean value that indicates whether
the traffic should be allowed or not. For example, if there is a
virtual network slice that isolates tenant1 from tenant2, the function
should return False when called with src=‘h1’, dst=‘h3’, and
app=‘app1’, where h1 belongs to tenant1 and h3 belongs to tenant2.
o To implement the virtual network slicing, you can use the
virtual network slices dictionary that is provided.