Question

In: Computer Science

In this assignment you will start with Python code that builds a 2 host network connected...

In this assignment you will start with Python code that builds a 2 host network connected by a legacy router. You will modify it such that the two hosts can send packets to each other. It requires that you understand subnet addressing and the function of a router. The network built using Miniedit on a Mininet virtual machine: python mininet/examples/miniedit.py. We need to also make 6 static routes to make the program work.

This is the work that I have so far!!

#!/usr/bin/python
from mininet.net import Mininet
from mininet.node import Controller, RemoteController,OVSController
from mininet.node import Host, Node
from mininet.node import OVSKernelSwitch, UserSwitch
from mininet.node import IVSSwitch
from mininet.cli import CLI
from mininet.log import setLogLevel, info
from mininet.link import TCLink, Intf
from subprocess import call


def myNetwork():
net = Mininet( topo=None, build=False,ipBase='10.0.0.0/24')
info( '*** Adding controller\n' )
c0=net.addController(name='c0',controller=Controller, protocol='tcp',port=6633)


s1 = net.addSwitch('s1', cls=OVSKernelSwitch)
s2 = net.addSwitch('s2', cls=OVSKernelSwitch)

info( '*** Add switches\n')
r5 = net.addHost('r5', cls=Node, ip=' 10.0.1.1/24', defaultRoute='via 192.168.56.1')
r5.cmd('sysctl -w net.ipv4.ip_forward=1')
r4 = net.addHost('r4', cls=Node, ip=' 10.0.2.1/24', defaultRoute='via 192.168.56.2')
r4.cmd('sysctl -w net.ipv4.ip_forward=1')
r3 = net.addHost('r3', cls=Node, ip=' 10.0.3.1/24', defaultRoute='via 192.168.56.3')
r3.cmd('sysctl -w net.ipv4.ip_forward=1')

info( '*** Add hosts\n')
h1 = net.addHost('h1', cls=Host, ip='10.0.0.1',defaultRoute='via 10.0.3.1')
h2 = net.addHost('h2', cls=Host, ip='10.0.0.2',defaultRoute='via 10.0.1.1')

info( '*** Add links\n')
net.addLink(h1, s1)
net.addLink(h2, s2)
net.addLink(s2, r5, intfName2='r5-eth1', params2={ 'ip' : '10.0.1.1/24'})
net.addLink(s1, r3, intfName2='r3-eth1', params2={ 'ip' : '10.0.3.1/24'})
net.addLink(r3, r4, intfName1='r3-eth2', params1={ 'ip' : '192.168.56.3'}, intfName1='r4-eth2', params0={'192.168.56.2'})
net.addLink(r4, r5, intfName1='r4-eth1', params1={ 'ip' : '10.0.2.1/24'}, intfName2='r5-eth2', params2={'192.168.56.1'})

info( '*** Starting network\n')
net.build()

info( '*** Starting controllers\n')
for controller in net.controllers:
controller.start()

info( '*** Starting switches\n')
net.get('s2').start([c0])
net.get('s1').start([c0])

info( '*** Post configure switches and hosts\n')
CLI(net)
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' )
myNetwork()

Solutions

Expert Solution

inuxrouter.py: Example network with Linux IP router
This example converts a Node into a router using IP forwarding
already built into Linux.
The example topology creates a router and three IP subnets:
- 192.168.1.0/24 (r0-eth1, IP: 192.168.1.1)
- 172.16.0.0/12 (r0-eth2, IP: 172.16.0.1)
- 10.0.0.0/8 (r0-eth3, IP: 10.0.0.1)
Each subnet consists of a single host connected to
a single switch:
r0-eth1 - s1-eth1 - h1-eth0 (IP: 192.168.1.100)
r0-eth2 - s2-eth1 - h2-eth0 (IP: 172.16.0.100)
r0-eth3 - s3-eth1 - h3-eth0 (IP: 10.0.0.100)
The example relies on default routing entries that are
automatically created for each router interface, as well
as 'defaultRoute' parameters for the host interfaces.
Additional routes may be added to the router or hosts by
executing 'ip route' or 'route' commands on the router or hosts.
"""
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.node import Node
from mininet.log import setLogLevel, info
from mininet.cli import CLI
class LinuxRouter( Node ):
"A Node with IP forwarding enabled."
def config( self, **params ):
super( LinuxRouter, self).config( **params )
# Enable forwarding on the router
self.cmd( 'sysctl net.ipv4.ip_forward=1' )
def terminate( self ):
self.cmd( 'sysctl net.ipv4.ip_forward=0' )
super( LinuxRouter, self ).terminate()
class NetworkTopo( Topo ):
"A LinuxRouter connecting three IP subnets"
def build( self, **_opts ):
defaultIP = '192.168.1.1/24' # IP address for r0-eth1
router = self.addNode( 'r0', cls=LinuxRouter, ip=defaultIP )
s1, s2, s3 = [ self.addSwitch( s ) for s in ( 's1', 's2', 's3' ) ]
self.addLink( s1, router, intfName2='r0-eth1',
params2={ 'ip' : defaultIP } ) # for clarity
self.addLink( s2, router, intfName2='r0-eth2',
params2={ 'ip' : '172.16.0.1/12' } )
self.addLink( s3, router, intfName2='r0-eth3',
params2={ 'ip' : '10.0.0.1/8' } )
h1 = self.addHost( 'h1', ip='192.168.1.100/24',
defaultRoute='via 192.168.1.1' )
h2 = self.addHost( 'h2', ip='172.16.0.100/12',
defaultRoute='via 172.16.0.1' )
h3 = self.addHost( 'h3', ip='10.0.0.100/8',
defaultRoute='via 10.0.0.1' )
for h, s in [ (h1, s1), (h2, s2), (h3, s3) ]:
self.addLink( h, s )
def run():
"Test linux router"
topo = NetworkTopo()
net = Mininet( topo=topo ) # controller is used by s1-s3
net.start()
info( '*** Routing Table on Router:\n' )
info( net[ 'r0' ].cmd( 'route' ) )
CLI( net )
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' )
run()

Related Solutions

In this assignment, you need to determine the network ID, first usable host, last usable host,...
In this assignment, you need to determine the network ID, first usable host, last usable host, range of valid addresses, and broadcast address of a network. Must be written on paper Which subnet (network ID) does host 192.24.54.215 255.255.255.240 belong to? What is the last valid host on the subnetwork 192.168.243.32 255.255.255.248? What is the first valid host on the subnetwork that the node 192.31.253.75/28 belongs to? What is the first valid host on the subnetwork that the node 192.24.91.245...
Python code Assignment Overview In this assignment you will practice with conditionals and loops (for). This...
Python code Assignment Overview In this assignment you will practice with conditionals and loops (for). This assignment will give you experience on the use of the while loop and the for loop. You will use both selection (if) and repetition (while, for) in this assignment. Write a program that calculates the balance of a savings account at the end of a period of time. It should ask the user for the annual interest rate, the starting balance, and the number...
This is an assignment for python. Download the code “ GradeBook.py ” You will be modifying...
This is an assignment for python. Download the code “ GradeBook.py ” You will be modifying the code to do the following: 1) create an empty dictionary named “FinalAverages” 2) In one for loop you will zip all lists together and get their individual members on each iteration. You can name these what ever you want. 3) on each iteration: Calculate the WEIGHTED average using the weights provided, and then add a new dictionary value to the dictionary “ FinalAverages...
This is a programming assignment!!! Start with the Assignment3.java source code posted to Canvas. This code...
This is a programming assignment!!! Start with the Assignment3.java source code posted to Canvas. This code outputs the programmer’s name , prompts the user to enter two numbers (integers) and outputs their sum. Note: When you run the program, it expects you to enter two integer values (a counting or whole number like 1, 216, -35, or 0) Make the following changes/additions to the code: On line 11, change the String myName from “your full name goes here!!!” to your...
can you please convert this python code into java? Python code is as shown below: #...
can you please convert this python code into java? Python code is as shown below: # recursive function def row_puzzle_rec(row, pos, visited):    # if the element at the current position is 0 we have reached our goal    if row[pos] == 0:        possible = True    else:        # make a copy of the visited array        visited = visited[:]        # if the element at the current position has been already visited then...
For Python: In this assignment you are asked to write a Python program to determine the...
For Python: In this assignment you are asked to write a Python program to determine the Academic Standing of a studentbased on their CGPA. The program should do the following: Prompt the user to enter his name. Prompt the user to enter his major. Prompt the user to enter grades for 3 subjects (A, B, C, D, F). Calculate the CGPA of the student. To calculate CGPA use the formula: CGPA = (quality points * credit hours) / credit hours...
Python: IDLE exercise 1. Start by running, in the shell, the following assignment statement: s1 =...
Python: IDLE exercise 1. Start by running, in the shell, the following assignment statement: s1 = 'abcdefghijklmnopqrstuvwxyz' Now write expressions—on separate lines of code—using sting s1 and the indexing operator that evaluate to 'm', 'p', 'z', 'e', 'a'. 2. Write Python statements that correspond to the following: a. assign to variable flowers a list containing strings 'rose', 'bougainvillea', 'yucca', 'marigold', 'daylily', and 'lily of the valley'. b. Write Boolean expressions that evaluate to True if the string ‘carrot’ is in...
minimum spanning tree: find a connected subgraph whose total edge cost is minimized (python code)
minimum spanning tree: find a connected subgraph whose total edge cost is minimized (python code)
Use python programming to write this code and provide a screen short for the code. 2....
Use python programming to write this code and provide a screen short for the code. 2. Write a function that takes one argument (a string) and returns a string consisting of the single character from that string with the largest value. Your function should contain a for loop. You can assume that the input to your function will always be a valid string consisting of at least one character. You can assume that the string will consist only of lower-case...
In python make a simple code. You are writing a code for a program that converts...
In python make a simple code. You are writing a code for a program that converts Celsius and Fahrenheit degrees together. The program should first ask the user in which unit they are entering the temperature degree (c or C for Celcius, and f or F for Fahrenheit). Then it should ask for the temperature and call the proper function to do the conversion and display the result in another unit. It should display the result with a proper message....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT