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

PA4_Gonzalez, Houser, Pettit, Reed

Team Leader: ​Marcus Gonzalez


OS, mininet, and network setup: ​All, each member worked on their own machine
Program changes and documentation of changes made: ​Gonzalez, Houser, Pettit
Testing and Debug: ​Gonzalez, Houser
Backup Leader: ​Adam Houser

Common topology as show in the lab:

1. Network Design:
● Gonzalez

● Houser
● Pettit

○ Network topology is as shown in the lab assignment, two hosts,


connected to a legacy router.
○ Each host will be placed on a separate subnet h1/24 and h2/24.
○ The function of a router (layer 3 device) is to connect separate networks
and forward packets.
○ The router will be configured to forward packets between the h1 and h2
subnets.
● Reed

2. List of changes made and why:

Final Code
from ​mininet.net ​import ​Mininet
from ​mininet.node ​import ​Host​, ​Node
from ​mininet.cli ​import ​CLI
from ​mininet.log ​import ​setLogLevel​, ​info
def ​myNetwork​():
# Change the ipbase from 10.0.0.0/8 to 10.0.1.0/24 allowing us to divide the address space
# into multiple subnets
net = Mininet(​topo​=​None​, ​build​=​False​, ​ipBase​=​'10.0.1.0/24'​)
info(​'*** Adding controller​\n​'​)
info(​'*** Adding switches​\n​'​)

​# Assign an IP address to the router


r1 = net.addHost(​'r1'​, ​cls​=Node​, ​ip​=​'10.0.1.1/24'​)

​# port forwarding is enabled


r1.cmd(​'sysctl -w net.ipv4.ip_forward=1'​)

info(​'*** Add host​\n​'​)


​ #assign h2 IP address as 10.0.1.2/24 and provide default route to 10.0.1.1
h2 = net.addHost(​'h2'​, ​cls​=Host​, ​ip​=​'10.0.1.2/24'​, ​defaultRoute​=​'via 10.0.1.1'​)

​#assign h2 IP address as 10.0.2.2/24 and provide default route to 10.0.2.1


h1 = net.addHost(​'h1'​, ​cls​=Host​, ​ip​=​'10.0.2.2/24'​, ​defaultRoute​=​'via 10.0.2.1'​)

info(​'***Add links​\n​'​)
​ #assign r1-eth1 10.0.1.1/24 connected to h2 at 10.0.1.2/24
net.addLink(h2​, ​r1​, ​intfName2​=​'r1-eth1'​, ​params2​={​'ip'​: ​'10.0.1.1/24'​})

​ assign r1-eth2 10.0.2.1/24 connected to h1 at 10.0.2.1/24


#
net.addLink(h1​, ​r1​, ​intfName2​=​'r1-eth2'​, ​params2​={​'ip'​: ​'10.0.2.1/24'​})

info(​'*** Starting network​\n​'​)


net.build()
CLI(net)
net.stop()

if ​__name__ == ​'__main__'​:
setLogLevel(​'info'​)
myNetwork()

Original code
from ​mininet.net ​import ​Mininet
from ​mininet.node ​import ​Host​, ​Node
from ​mininet.cli ​import ​CLI
from ​mininet.log ​import ​setLogLevel​, ​info

def ​myNetwork​():
net = Mininet(​topo​=​None​, ​build​=​False​,
​ipBase​=​'10.0.0.0/8'​)

info(​'*** Adding controller​\n​'​)


info(​'*** Add switches​\n​'​)
r1 = net.addHost(​'r1'​, ​cls​=Node​, ​ip​=​'0.0.0.0'​)
r1.cmd(​'sysctl -w net.ipv4.ip_forward=1'​)

info(​'*** Add hosts​\n​'​)


h2 = net.addHost(​'h2'​, ​cls​=Host​, ​ip​=​'10.0.0.2'​, ​defaultRoute​=​None​)
h1 = net.addHost(​'h1'​, ​cls​=Host​, ​ip​=​'10.0.0.1'​, ​defaultRoute​=​None​)
info(​'*** Add links​\n​'​)
net.addLink(h1​, ​r1)
net.addLink(h2​, ​r1)
info(​'*** Starting network​\n​'​)
net.build()
CLI(net)
net.stop()
if ​__name__ == ​'__main__'​:
setLogLevel(​'info'​)
myNetwork()

Changes:
We updated the IP addresses to make it a little easier on the brain to read, 1 and 2 for host 1
and 2, and then used a /24 mask to split the subnets at that level. The /8 subnet mask originally
wasn’t discrete enough to differentiate between our subnets.

We also put in the default route to flow each host back through the appropriate link off the
router.

3. Screen capture of the programming running with no Python errors (needed only if
step 4 and step 5 below don’t work.

4. Screen capture of successful h1 ping h2 command at the mininet prompt:

5. Screen capture of successful h2 ping h1 command at the mininet prompt:

6. Questions:
a. What were any interesting things found and lessons learned?

As we discussed programming options, some of us found the option to just ignore


the switches completely and go directly from host to router interesting. As a
group we tried to accomplish this lab a few different ways, and unfortunately, the
above was the only way we could find that worked. We think there’s multiple
ways to approach this, and attempted to get a couple ideas working, but sadly,
time constraints left us where we are.
Understanding the subnets seems like a “devil is in the details” type of thing.

b. Why didn’t the original program forward packets between hosts?

There was no default route and as it was setup, the mask was not discrete
enough.

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

Yes, without this line both hosts can ping the router, but it will not forward
anything between subnets, so h1 cannot ping 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.

We elected to change the subnet mask of h1 from /24 to /8. This change broke
the program and made h2 unreachable from h1, and h1 unreachable from h2.
Changing the subnet mask, changes the network segment portion of the IP
address. This moves the host to an unrecognized subnet with no default route to
reach other hosts on the network.

You might also like