Python代写|CS 352 Internet Technology Project #5: Set up your own IP network

这是一篇美国的计算机网络python代写

Please read these instructions carefully before you begin.

In this project, you will set up a small IP network consisting of hosts and a router. Your network will function with full end-to-end connectivity, and you will experiment with tools like ping and traceroute.

Consider the following network topology:

Here, r1 is an IP router and h1 … h4 are endpoints. In a safe experimental setting running inside a virtual machine, you will use the ip suite of commands to set up the right IP addresses for all the interfaces, and the right routing table entries for all the routers and endpoints in this network. Welcome to the AS352 network!

To create a safe virtualized environment, we will use a tool called mininet, which uses linux containers (see https://en.wikipedia.org/wiki/Linux_namespaces) to allow you to create a small network of hosts and routers that can run inside your laptop. (If you’re interested in learning more about mininet, you can read about it from the paper entitled “A network in a laptop: Rapid prototyping for software-defifined networks,” found at http://conferences.sigcomm.org/hotnets/2010/papers/a19-lantz.pdf.)

First, download the standard mininet virtual machine (note, this is a 500+ MByte fifile).

https://github.com/mininet/mininet/releases/download/2.2.2/mininet-2.

2.2-170321-ubuntu-14.04.4-server-i386.zip

Set up the VM and play around according to the instructions at the link below. We recommend that you use VirtualBox. By the end of this step, you must be able to log into the VM and run basic terminal commands like ls.

http://mininet.org/vm-setup-notes/

Within the virtual machine, run the attached network topology fifile, AS352.py, which invokes mininet’s Python API to create a network topology with 4 endpoints (hosts) and 1 router. Note the use of sudo while running the program. Note that this program will be unsuccessful on any machine without a viable mininet installation. In particular, you cannot run AS352.py on ilab.

mininet@mininet-vm:˜/project5$ sudo python AS352.py

*** Creating network

*** Adding controller

*** Adding hosts:

h1 h2 h3 h4 r1

*** Adding switches:

*** Adding links:

(h1, r1) (h2, r1) (h3, r1) (h4, r1)

*** Configuring hosts

h1 h2 h3 h4 r1

*** Starting controller

*** Starting 0 switches

*** Routing Table on Router:

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

*** Starting CLI:

mininet>

Within the mininet shell, you can do various things to control the hosts and router we just instantiated. One highly convenient aspect of mininet is that the hosts, the router, and the VM all share the same fifilesystem, so the same fifiles are visible from all hosts and the router. Also, you can run commands, dump outputs into a fifile, and access it from any host or router or a regular terminal inside the VM. Let’s walk through a few examples of playing around with the mininet topology.

Step 2.1. Run the ls command on host h1.

mininet> h1 ls

mininet>

Note that the command is prefifixed by h1 to indicate to mininet that the command must be run on host h1. You can replace ls by any command which can run on h1, by just typing

h1 <command>

where <command> is any command that would run on a regular Linux terminal. You can run ls on any host or router by changing the prefifix of the command:

<host or router name> ls

Step 2.2. Inspect the network topology from within mininet:

mininet> net

h1 h1-eth0:r1-eth1

h2 h2-eth0:r1-eth2

h3 h3-eth0:r1-eth3

h4 h4-eth0:r1-eth4

r1 r1-eth1:h1-eth0 r1-eth2:h2-eth0 r1-eth3:h3-eth0 r1-eth4:h4-eth0c0

mininet>

Note that net is not prefifixed by any host or router name. It is a native mininet command.

Step 2.3. You can even run commands on the router! Mininet allows you to treat both endpoints and the router as standard Linux machines, on which you get to run “regular” Linux commands.

Let’s dump the routing table on r1.

mininet> r1 ip route

mininet>

By default, there is nothing in the routing table on r1. As you may have guessed, that is one of the things that you will add in this project.

Step 2.4. Mininet can also read a list of commands from a fifile. Suppose we added the text

r1 ip route

into the fifile commands.txt. Then, you can use the source mininet command to run all the commands in sequence, one after another. For example:

mininet> source commands.txt

AS352.py commands.txt

h1 h1-eth0:r1-eth1

h2 h2-eth0:r1-eth2

h3 h3-eth0:r1-eth3

h4 h4-eth0:r1-eth4

r1 r1-eth1:h1-eth0 r1-eth2:h2-eth0 r1-eth3:h3-eth0 r1-eth4:h4-eth0c0

mininet>

You can fifind more examples of mininet commands and usage at http://mininet.org/walkthrough/#interact-with-hosts-and-switches