Starting from:

$30

CS352-Project 3 Setting up IP Network Solved

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:

 

h1      h2

    \   /

      R1

    /   \

h3      h4

 

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!

 

Step 1: Set up mininet
--------------

 

To create a safe virtualized environment, we will use a tool called mininet, which uses linux containers (see ref. [1]) to allow you to create a small network of hosts and routers that can run inside your laptop. You can read more about mininet from ref. [2].

 

First, download the standard mininet virtual machine (VM) from here (mininet 2.2.2, ubuntu 14.04):

https://github.com/mininet/mininet/releases/download/2.2.2/mininet-2.2.2-170321-ubuntu-

14.04.4-server-i386.zip

[large file -- 500+ MByte]

(Please make sure the URL you entered is exactly the same as the above!)

 

Set it up and play around according to the instructions: 

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

 

Follow instruction in the above link, to download and install a virtualization program such as: VMware Workstation for Windows or Linux, VMware Fusion for Mac, VirtualBox ( free!, GPL) for any platform, or qemu ( free!, GPL) for Linux.  

 

We recommend that you use VirtualBox.  

 

By the end of this, you must be able to log into the VM using ssh and transfer files into VM (If not, follow the instruction in the above link!).

 

Step 2: Play with the topology Python file
----------------------------------

 

Run the attached network topology file, 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.  

 

``````` 

mininet@mininet-vm:~/project3$ 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 c0  

*** 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 filesystem, so the same files are visible from all hosts and the router. Also, you can run commands, dump outputs into a file, and access it from any host or router or a regular terminal inside the VM.

 

A few examples of playing around with the mininet topology.

 

- Run the `ls` command on host h1. 

 

``````` 

mininet> h1 ls 

AS352.py  commands.txt mininet>  

``````` 

 

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

 

h1 <command>

 

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

 

<host or router name> ls

 

- 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-eth0 c0 mininet> 

``````` 

 

Note that `net` is not prefixed by any host or router name, since it is a native mininet command.

 

-  You can even run commands on the router! Mininet is cool because you get to treat both endpoints and the router as standard Linux machines on which you get to do "regular" things. Let's dump the routing table on r1. 

 

``````` 

mininet> r1 ip route mininet>  

``````` 

 

There is nothing in the routing table on r1. As you may have guessed, that is one of the things that you will fix in this project.

 

-  Mininet can also read a list of commands from a file. Suppose we added the text

 

h1 ls net r1 ip route

 

into the file `commands.txt`. Then, you can use the `source` mininet command to run all the commands in sequence, one after another.

 

``````` 

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-eth0 c0 mininet>  

``````` 

 

- You can find more examples at 

http://mininet.org/walkthrough/#interact-with-hosts-and-switches

 

 

Step 3: Setting up your network
-----------------------

 

Now we come to the crux of the project. You need to set up the network interfaces on all hosts and routers, as well as the routing tables, so that end to end IP communication is possible between all hosts and the router interfaces. You will do this in three steps.

 

(1) Set up the IP addresses of all interfaces. 

 

You will use the following IP addresses for each interface:

 

10.0.0.2 h1-eth0

192.168.0.2 h2-eth0

10.0.0.4 h3-eth0

192.168.0.4 h4-eth0

10.0.0.1 r1-eth1

192.168.0.1 r1-eth2

10.0.0.3 r1-eth3

192.168.0.3 r1-eth4

 

Use the `ip addr` command to set up the correct IP address for each interface on each machine. You need to set up 8 interface addresses in total. If you need help in using the command, try running `ip addr help`.

 

(2)  Set up the default routes for the hosts. 

 

The hosts h1…h4 are only connected to the rest of the network through one interface. Any external communication must hence use a "default" route, which moves the packets on the host towards the router.

 

For example, all traffic on host h1 must use the interface/device h1-eth0 to reach any destination (other than itself).

 

Use the `ip route` command to do this. If you need help understanding the command, try running `ip route help`. You will set up 4 default routes, one for each endpoint h1...h4.

 

(3)  Set up the routes on the router. 

 

The last remaining piece is having the router interconnecting the endpoints match the packets with the correct outgoing network interface.

 

The forwarding table entries on router r1 conceptually must look like:

 

Destination IP address -> Port h1 (10.0.0.2) -> r1-eth1 h2 (192.168.0.2) -> r1-eth2 h3 (10.0.0.4) -> r1-eth3

h4 (192.168.0.4) -> r1-eth4

 

Once again, use the `ip route` command to set up these routes. You will need to set up 4 routes, one for each destination endpoint.

 

(4)  Test your network 

 

You've done all the hard work. Now test whether your network works as intended, using the ping and traceroute commands. A correctly configured network must be able to execute a successful `ping` from any host or the router to any valid IP address inside the network.

 

For example, you can ping h4 from h1, to check reachability:

 

``````` 

mininet> h1 ping 192.168.0.4 

PING 192.168.0.4 (192.168.0.4) 56(84) bytes of data. 

64 bytes from 192.168.0.4: icmp_seq=1 ttl=63 time=168 ms 

64 bytes from 192.168.0.4: icmp_seq=2 ttl=63 time=0.046 ms 

64 bytes from 192.168.0.4: icmp_seq=3 ttl=63 time=0.044 ms 

^C 

--- 192.168.0.4 ping statistics --- 

3 packets transmitted, 3 received, 0% packet loss, time 2004ms rtt min/avg/max/mdev = 0.044/56.315/168.855/79.577 ms mininet>  

``````` 

 

You can also run traceroute between any two points. For example, a traceroute from h1 to h4 would show something like this:

 

``````` 

mininet> h1 traceroute 192.168.0.4 

traceroute to 192.168.0.4 (192.168.0.4), 30 hops max, 60 byte packets 

 1  10.0.0.1 (10.0.0.1)  0.018 ms  0.003 ms  0.003 ms  2  192.168.0.4 (192.168.0.4)  0.008 ms  0.003 ms  0.004 ms mininet>  

``````` 

More products