You are on page 1of 9

Team 8:

Bablu Banik
Javier Gonzalez
Jordan Guzman
Ashley Teraishi

Programming Assignment #4 Subnet Addressing in Mininet


Steps 1 - 5

Step 1. Network Design


Steps 2 & 3. Screenshot

Step 4. List of lines that were changed and why

There are 5 blocks of code where differences were seen


between the old code and the working code.
Block 1 (topography): We removed the old code and set it to
topo=None in order to use a custom topography for the
network.

Block 2 (switches and routers): The switches and routers were


created together in the old code. Professor Satyavolu said that
there needed to be a correct order in which they were created
and wired.

Block 3 (hosts): The ordering is different here as well - h2 was


created first in the old code while h1 is created first in the new
code. The new code also adds masks to the IP addresses and
uses a default route IP. We needed to add a default route for
the program to be capable of forwarding packets between
hosts.

Block 4 (links): The ordering is different here. This is where


professor Satyavolu’s advice was crucial. The ordering of linking
hosts, routers, switches, and the controller needed to be
precise in order for the network to function properly.

Block 5 (static routes): In the old code, we did not add static
routes. We did this in the new code so that packets can be
forwarded between hosts.
Old Blocks of Code New/Changed Blocks of Code
net = Mininet( topo=None, net = Mininet(topo=None)
build=False,
ipBase='10.0.0.0/8')
info( '*** Add switches\n') info( '*** Add switches\n')
s1 = net.addSwitch('s1',
r3 = net.addHost('r3', cls=OVSKernelSwitch)
cls=Node, ip='0.0.0.0') s2 = net.addSwitch('s2',
cls=OVSKernelSwitch)
r3.cmd('sysctl -w
net.ipv4.ip_forward=1') info('*** Add routers\n')
r3 = net.addHost('r3',
s1 = net.addSwitch('s1', cls=Node, ip='10.0.5.1/24')
cls=OVSKernelSwitch)
r3.cmd('sysctl -w
r5 = net.addHost('r5', net.ipv4.ip_forward=1')
cls=Node, ip='0.0.0.0')
r4 = net.addHost('r4',
r5.cmd('sysctl -w cls=Node,
net.ipv4.ip_forward=1') ip='192.168.1.2/30')

s2 = net.addSwitch('s2', r4.cmd('sysctl -w
cls=OVSKernelSwitch) net.ipv4.ip_forward=1')

r4 = net.addHost('r4', r5 = net.addHost('r5',
cls=Node, ip='0.0.0.0') cls=Node, ip='10.0.6.1/24')

r4.cmd('sysctl -w r5.cmd('sysctl -w
net.ipv4.ip_forward=1') net.ipv4.ip_forward=1')
h2 = net.addHost('h2', h1 = net.addHost('h1',
cls=Host, ip='10.0.0.2', cls=Host, ip='10.0.5.2/24',
defaultRoute=None) defaultRoute='via 10.0.5.1')
h1 = net.addHost('h1', h2 = net.addHost('h2',
cls=Host, ip='10.0.0.1', cls=Host, ip='10.0.6.2/24',
defaultRoute=None) defaultRoute='via 10.0.6.1')

net.addLink(h1, s1) net.addLink(h1, s1)


net.addLink(s1, r3) net.addLink(h2, s2)
net.addLink(r3, r4) net.addLink(s1, r3)
net.addLink(r4, r5) net.addLink(s2, r5)
net.addLink(r5, s2) net.addLink(r3, r4,
net.addLink(s2, h2) intfName1='r3-eth1',
params1={ 'ip' :
'192.168.1.1/30'},
intfName2='r4-eth0',
params2={ 'ip' :
'192.168.1.2/30'} )

net.addLink(r4, r5,
intfName1='r4-eth1',
params1={ 'ip' :
'192.168.2.1/30'},
intfName2='r5-eth1',
params2={ 'ip' :
'192.168.2.2/30'} )
# Adds static routes
r3.cmd('route add -net
10.0.6.0/24 gw 192.168.1.2
r3-eth1')

r3.cmd('route add -net


192.168.2.0/30 gw
192.168.1.2 r3-eth1')

r4.cmd('route add -net


10.0.5.0/24 gw 192.168.1.1
r4-eth0')

r4.cmd('route add -net


10.0.6.0/24 gw 192.168.2.2
r4-eth1')

r5.cmd('route add -net


10.0.5.0/24 gw 192.168.2.1
r5-eth1')

r5.cmd('route add -net


192.168.1.0/30 gw
192.168.2.1 r5-eth1')
Step 5. Answers to Questions

a) What were any interesting findings and lessons learned?


This final programming assignment was challenging. It requires one to have deep

knowledge of how to assign IPs among hosts, routers, switches, etc. It also requires

sufficient command of python programming skills to handle everything programmatically. Apart

from these two, the followings are the interesting lessons:

1. net = Mininet( topo=None, build=False, ipBase='10.0.0.0/8'). If one is going to

use custom IPs like PA#4, he needs to have net = Mininet( topo=None). The custom

IPs do not work with the "build=False, ipBase='10.0.0.0/8'".

2. Though we have not used it, we recommend using variables for all addresses

instead of using hard-coded variables. For example:

// this is with hard-coded IP


info('*** Add routers\n')
r3 = net.addHost('r3', cls=Node, ip='10.0.5.1/24')
r3.cmd('sysctl -w net.ipv4.ip_forward=1')
r4 = net.addHost('r4', cls=Node, ip='192.168.1.2/30')
r4.cmd('sysctl -w net.ipv4.ip_forward=1')
r5 = net.addHost('r5', cls=Node, ip='10.0.6.1/24')
r5.cmd('sysctl -w net.ipv4.ip_forward=1')
info( '*** Add hosts\n')
h1 = net.addHost('h1', cls=Host, ip='10.0.5.2/24', defaultRoute='via 10.0.5.1')
h2 = net.addHost('h2', cls=Host, ip='10.0.6.2/24', defaultRoute='via 10.0.6.1')

// now same code with variables


r3IP = '10.0.5.1/24'
h1NetWork = '10.0.5.2/24'
r4IP = '192.168.1.2/30'
r5IP = '10.0.6.1/24'
h2NetWork = '10.0.6.2/24'
info('*** Add routers\n')
r3 = net.addHost('r3', cls=Node, ip=r3IP)
r3.cmd('sysctl -w net.ipv4.ip_forward=1')
r4 = net.addHost('r4', cls=Node, ip=r4IP )
r4.cmd('sysctl -w net.ipv4.ip_forward=1')
r5 = net.addHost('r5', cls=Node, ip=r5IP )
r5.cmd('sysctl -w net.ipv4.ip_forward=1')
info( '*** Add hosts\n')
h1 = net.addHost('h1', cls=Host, ip=h1NetWork, defaultRoute='via '+r3IP)
h2 = net.addHost('h2', cls=Host, ip=h2NetWork , defaultRoute='via '+r5IP )

So one needs to adjust IP for one or more entities, he can do it in the variables
without touching the rest of the code.

3. Adding static routes are needed. One can add them manually or programmatically. If one

chooses to add programmatically, these routes persist as long as the program is running.

Adding manually will require removing manually. So the recommendation is for

programmatic additions.

b) Why didn’t the original program forward packets between the hosts?
The original program does not forward packets between the hosts due to the following reasons:

1. There is no static route and the default Route is set to none.

2. For adding links between r3 and r4, the required r3-eth1 and r4-eth0 were not set

up. A similar issue exists between r4 and r5.

c) Is the line ‘ r3.cmd('sysctl -w net.ipv4.ip_forward=1') ’ required?


Yes, the line ‘ r3.cmd('sysctl -w net.ipv4.ip_forward=1') ’ is required. Omission of

this line causes at least a 30 % drop and the packets do not get transmitted

between h1 and h2.


d) Intentionally break your working program, e.g.: change a subnet length,
IP address, or default route for a host. Explain why your change caused the
network to break.
Originally, our code was not able to pass the test of "pingall" command. We always had a 10%
drop. This is due to a minor mistake on our part. Now we have solved it. However, for this
question, I will intentionally break my working program by repeating the mistake. r3.cmd('route
add -net 192.168.2.0/30 gw 192.168.2.2 r3-eth1') Here one static route is added with the
gateway r5-eth0. It is not correct. Due to this incorrect gateway, the system always has at least
a 10% drop during "pingall" command. The correct gateway should be r4-eth0. So the correct
static route is r3.cmd('route add -net 192.168.2.0/30 gw 192.168.1.2 r3-eth1')

You might also like