联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> Database作业Database作业

日期:2024-05-17 09:07

COMP 4911 Winter 2024

Assignment 5

In this assignment, you will write a Python program using Mininet API to create and configure an IP network similar to the “how many subnets” network from class:

Note that there is only one host per subnet (this is due to a limitation of how we are using Mininet) and that the address prefix has been changed.

Your goal is to have all hosts and routers be able to communicate with each other. The Mininet ‘pingall’ command is useful for testing this. There are examples in the mininet/examples folder (on your Mininet Virtual Machine) that you can use as a guide.

Each host and router should have forwarding table entries to allow communication between all nodes. For this assignment, you will configure these entries using ‘static routes’ – entries that are added manually, as opposed to using a routing protocol to add them automatically. You will need to determine the appropriate entries for each host and router, and then add them using Linux commands.

Hints

 These Linux manual pages will be helpful: ifconfig(8), netstat(8), ip (8), ip-route(8), route(8). For example, use man ifconfig to view the ifconfig man page. You can use netstat -rn or ip route show to see the forwarding table on a Linux host.

 You can run Linux commands from a Mininet program. See the sample files for examples of this.

 You can test your configuration by running commands from an xterm window for a specific host or router before adding them to your program. You can also run commands on a Mininet host (or router) from the Mininet> prompt (see below).

How to get started

1. Download the sample network from Moodle (‘a5-sample-net.py’) and copy it to your Mininet virtual machine. There are two routers, two hosts, and three subnets, each with a /24 prefix:

Run the sample using ‘sudo -E python3 a5-sample-net.py’. Note that you don’t run Mininet (mn) explicitly in this case. The program is an example of using the Mininet API directly in a Python program.

Examine the forwarding table for each of the hosts and routers in this sample network. For example, here is the forwarding table for router r1:

    mininet> r1 ip route show

    10.0.1.0/24 dev r1-eth0 proto kernel scope link src 10.0.1.254

    10.0.2.0/24 via 192.168.1.2 dev r1-eth1

    192.168.1.0/24 dev r1-eth1 proto kernel scope link src 192.168.1.1

    Note that you can also run ip route show from an r1 xterm window.

We can see that r1 has three entries in its forwarding table. The routes for subnets 10.0.1.0/24 and 192.168.1.0/24 are directly connected, i.e. they are for subnets for which r1 has an interface. The route for 10.0.2.0/24 is an indirect route, since it specifies the router interface (‘via 192.168.1.2’) that r1 must send packets to so they can reach hosts on the 10.0.2.0/24 subnet. Try commenting out some of the lines that add forwarding table entries, and then observe what changes.

Be sure that you understand what the information in the forwarding table means. Review this example and the information in section 4.3 of the textbook until you do.

Verify that all hosts and routers can communicate with each other with the Mininet pingall command. You should see ‘*** Results: 0% dropped (12/12 received)’.

2. You are now ready to begin. Using the sample as a template, create a Python file that will build and run your network. Assign addresses for all host and router interfaces. Note that the names of the network interfaces are determined by the order that links are added between nodes (see comment in the sample).

3. Determine what the forwarding table for each host and router should look like to allow communication between all hosts.

4. Implement the network using the Mininet API. Use the examples in ‘comp4911/assignment4’ as a guide. There are comments in these examples that will guide you. Also consult the Mininet Python API Reference Manual: http://mininet.org/api/annotated.html

5. You will need to set up the forwarding tables on each of the routers in your network. You do this by adding routes for all destination subnets (see the example code).

6. Use the Mininet pingall command to test connectivity in your network.

7. Create a diagram of your network, using the diagram above as a template, that includes clear labelling for

a. all IP addresses

b. all network interface names (e.g. ‘h1-eth0’, ‘r1-eth0’, etc.)

c. all subnets (use CIDR notation)

d. the entries in all forwarding tables (hosts and routers)

What to hand in

Make sure your code is well-documented with comments.

Submit your Python source code in a file named a5-network.py.

Submit your diagram in a PDF file named a5-network.pdf.





版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp