Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Exp no: 3C Viewing, Reading, and Writing Flow Table

Date: Rules for POX using Mininet Simulator

Aim:

The aim of this lab is to understand how to view and write flow table rules for a POX
controller using the Mininet network simulator. By completing this lab, you will gain hands-
on experience in inspecting and modifying flow table entries to control network traffic within
a simulated environment.

Materials Required:

• Computer with Mininet and POX installed


• Basic knowledge of Linux commands
• Python
• Terminal Emulator
• Text editor
Experiment Overview:

In this experiment, we will create a simple network topology using Mininet and use the POX
controller to manage the network. We will then inspect the flow table entries on the switch
and write custom flow table rules using the POX controller to manipulate network traffic.

Experiment Steps:

1. Setting up the Environment:

• Open a terminal on your computer.


• Launch Mininet with the following command to create a basic network topology:

sudo mn --topo single,3 --controller remote

This command creates a network with one switch and three hosts, with the controller
running remotely.
2. Start the POX Controller:

• Open a new terminal window.


• Navigate to the directory where POX is installed.
• Start the POX controller with the following command:

[bash]

./pox.py forwarding.l2_learning

This command starts the default l2_learning module, which implements a simple MAC-
learning switch.

3. Verify Connectivity:

• Return to the Mininet terminal.


• Test connectivity between hosts by pinging each other:

mininet> h1 ping h2

4. Viewing Flow Table Entries:

• In the POX terminal, you will observe log messages indicating the learning process.
• To view the flow table entries on the switch, open a new terminal window.
• Use the following command to dump the flow table entries:

[lua]

sudo ovs-ofctl -O OpenFlow13 dump-flows s1

This command displays the flow table entries for switch s1.
5. Writing Custom Flow Table Rules:

• Open a text editor and create a new Python file named custom_controller.py.
• Write Python code to implement custom flow table rules. Below is a sample code to
block ICMP traffic between hosts h1 and h2:
[python]

from pox.core import core


import pox.openflow.libopenflow_01 as of

log = core.getLogger()

def _handle_ConnectionUp(event):
log.info("ConnectionUp: %s", event.connection)
msg = of.ofp_flow_mod()
msg.match.dl_type = 0x0800 # IPv4
msg.match.nw_proto = 1 # ICMP
msg.match.nw_src = event.parse_ipv4("10.0.0.1")
msg.match.nw_dst = event.parse_ipv4("10.0.0.2")
msg.actions.append(of.ofp_action_output(port=of.OFPP_NONE))
event.connection.send(msg)

def launch():
core.openflow.addListenerByName("ConnectionUp", _handle_ConnectionUp)

• Save the file and exit the text editor.

6. Running the Custom Controller:

• In the POX terminal, stop the current controller by pressing Ctrl+C.


• Start the custom controller with the following command:

[bash]

./pox.py custom_controller
7. Observing Output:

• Observe the Mininet terminals to see if the ping between hosts h1 and h2 is
successful.
• Use the flow table dumping command to verify if the custom flow table rule has been
applied on the switch.
OUTPUT:

Terminal 1: Mininet
Terminal 2: POX Controller

Terminal 3: Custom Controller Logs

RESULT:

Through this experiment, we have learned how to view and write flow table rules for
a POX controller using the Mininet network simulator.

You might also like