User Tools

Site Tools


assignments-s18:assignment-2-s18:start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
assignments-s18:assignment-2-s18:start [2018/02/14 15:54]
hyuncong
assignments-s18:assignment-2-s18:start [2018/02/21 16:40] (current)
hyuncong
Line 12: Line 12:
   * Determine the matching route table entry for a given IP address   * Determine the matching route table entry for a given IP address
   * Develop a router that updates and forwards packets based on network layer headers   * Develop a router that updates and forwards packets based on network layer headers
- 
-====== Clarifications ====== 
-The topology files linear5_sw.topo and inclass_sw.topo have a typo. You should add a dash (-) to the end of the first line of each file. 
  
 ====== Part 1: Getting Started ====== ====== Part 1: Getting Started ======
Line 38: Line 35:
   - ItemDownload the starter code from:{{ :​assignments-s18:​assignment-2-s18:​assign2.tgz |assign2}} <​code>​   - ItemDownload the starter code from:{{ :​assignments-s18:​assignment-2-s18:​assign2.tgz |assign2}} <​code>​
 cd ~ cd ~
-wget  http://​pages.cs.wisc.edu/​~suman/​courses/​wiki/​lib/​exe/​fetch.php?​media=assignments-s18:​assignment-2-s18:​assign2.tgz+wget  http://​pages.cs.wisc.edu/​~suman/​courses/​wiki/​lib/​exe/​fetch.php?​media=assignments-s18:​assignment-2-s18:​assign2.tgz -O assign2.tgz
 tar xzvf assign2.tgz tar xzvf assign2.tgz
 </​code>​ </​code>​
Line 52: Line 49:
  
 ===== Running the Virtual Switch ===== ===== Running the Virtual Switch =====
-  ​Start Mininet emulation by running the following commands: <​code>​+  ​Start Mininet emulation by running the following commands: <​code>​
 $ cd ~/assign2/ $ cd ~/assign2/
 $ sudo ./​run_mininet.py topos/​single_sw.topo -a $ sudo ./​run_mininet.py topos/​single_sw.topo -a
Line 84: Line 81:
 </​code>​ </​code>​
 Keep this terminal open, as you will need the mininet command line for debugging. (Don’t press ctrl-z.) Keep this terminal open, as you will need the mininet command line for debugging. (Don’t press ctrl-z.)
-  ​Open another terminal. Start the controller, by running the following commands:<​code>​+  ​Open another terminal. Start the controller, by running the following commands:<​code>​
 cd ~/assign2/ cd ~/assign2/
 ./​run_pox.sh ./​run_pox.sh
Line 111: Line 108:
 Keep POX running. (Don't press ctrl-z.) Keep POX running. (Don't press ctrl-z.)
 Note that POX is used “under the hood” in this assignment to direct packets between Mininet and your virtual switch and virtual router instances (i.e., Java processes). You do not need to understand, modify, or interact with POX in any way, besides executing the run_pox.sh script. Note that POX is used “under the hood” in this assignment to direct packets between Mininet and your virtual switch and virtual router instances (i.e., Java processes). You do not need to understand, modify, or interact with POX in any way, besides executing the run_pox.sh script.
-  ​Open a third terminal. Build and start the virtual switch, by running the following commands:<​code>​+  ​Open a third terminal. Build and start the virtual switch, by running the following commands:<​code>​
 cd ~/assign2/ cd ~/assign2/
 ant ant
Line 124: Line 121:
 <-- Ready to process packets --> <-- Ready to process packets -->
 </​code>​ </​code>​
-  ​Go back to the terminal where Mininet is running. To issue a command on an emulated host, type the hostname followed by the command in the Mininet console. Only the host on which to run the command should be specified by name; any arguments for the command should use IP addresses. For example, the following command sends 2 ping packets from h1 to h2:<​code>​+  ​Go back to the terminal where Mininet is running. To issue a command on an emulated host, type the hostname followed by the command in the Mininet console. Only the host on which to run the command should be specified by name; any arguments for the command should use IP addresses. For example, the following command sends 2 ping packets from h1 to h2:<​code>​
 mininet> h1 ping -c 2 10.0.1.102 mininet> h1 ping -c 2 10.0.1.102
 </​code>​ </​code>​
Line 153: Line 150:
     icmp_code: 0     icmp_code: 0
 </​code>​ </​code>​
-  ​You can stop your virtual switch by pressing ctrl-c in the terminal where it’s running. You can restart the simple router without restarting POX and mininet, but it’s often useful to restart POX and mininet to ensure the emulated network starts in a clean state.+  ​You can stop your virtual switch by pressing ctrl-c in the terminal where it’s running. You can restart the simple router without restarting POX and mininet, but it’s often useful to restart POX and mininet to ensure the emulated network starts in a clean state.
  
 **Note:** **Note:**
Line 160: Line 157:
 ===== Code Overview ===== ===== Code Overview =====
 The virtual network code consists of the following important packages and classes: The virtual network code consists of the following important packages and classes:
-  * edu.wisc.cs.sdn.vnet — no need to modify code in this package+  * edu.wisc.cs.sdn.vnet — **no need** to modify code in this package
     * The main method (Main)     * The main method (Main)
     * Classes representing a network device and interfaces (Device, Iface)     * Classes representing a network device and interfaces (Device, Iface)
     * Code for creating a PCAP file containing all packets sent/​received by a network device (DumpFile)     * Code for creating a PCAP file containing all packets sent/​received by a network device (DumpFile)
-  * edu.wisc.cs.sdn.vnet.rt ​ — add/modify code in this package to complete Part 3+  * edu.wisc.cs.sdn.vnet.rt ​ — **add/modify** code in this package to complete Part 3
     * Skeleton code for a virtual router (Router)     * Skeleton code for a virtual router (Router)
     * A complete implementation of an ARP cache (ArpCache, ArpEntry)     * A complete implementation of an ARP cache (ArpCache, ArpEntry)
     * A partial implementation of a route table (RouteTable,​ RouteEntry)     * A partial implementation of a route table (RouteTable,​ RouteEntry)
-  * edu.wisc.cs.sdn.vnet.sw ​ — add/modify code in this package to complete ​Part 2+  * edu.wisc.cs.sdn.vnet.sw ​ — **add/modify** code in this package to complete ​part 2
     * Skeleton code for a virtual switch (Switch)     * Skeleton code for a virtual switch (Switch)
-    ​* net.floodlightcontroller.packet — no need need to modify code in this package +  ​* net.floodlightcontroller.packet — **no need** need to modify code in this package 
-    * Code for parsing and manipulating packet headers+      * Code for parsing and manipulating packet headers
  
-There are also several supporting packages and classes, which you do not need to modify or understand:+There are also several supporting packages and classes, which you **do not need to modify or understand**:
   * Itemedu.wisc.cs.sdn.vnet.vns — code to communicate with POX   * Itemedu.wisc.cs.sdn.vnet.vns — code to communicate with POX
   * org.openflow.util — code for manipulating special types   * org.openflow.util — code for manipulating special types
Line 183: Line 180:
  
 ===== Forwarding Packets ===== ===== Forwarding Packets =====
-You should complete the handlePacket(...) method in the edu.wisc.cs.sdn.vnet.sw.Switch class to send a received packet out the appropriate interface(s) of the switch. You can use the getSourceMAC() and getDestinationMAC() methods in the net.floodlightcontroller.packet.Ethernet class to determine the source and destination MAC addresses of the received packet.+You should complete the **handlePacket(...)** method in the **edu.wisc.cs.sdn.vnet.sw.Switch** class to send a received packet out the appropriate ​**interface(s)** of the switch. You can use the **getSourceMAC()** and **getDestinationMAC()** methods in the **net.floodlightcontroller.packet.Ethernet** class to determine the source and destination MAC addresses of the received packet.
  
  
-You should call the sendPacket(...) function inherited from the edu.wisc.cs.sdn.vnet.Device class to send a packet out a specific interface. To broadcast/​flood a packet, you can call this method multiple times with a different interface specified each time. The interfaces variable inherited from the Device class contains all interfaces on the switch. The interfaces on a switch only have names; they do not have MAC addresses, IP addresses, or subnet masks.+You should call the **sendPacket(...)** function inherited from the **edu.wisc.cs.sdn.vnet.Device** class to send a packet out a specific interface. To broadcast/​flood a packet, you can call this method multiple times with a different interface specified each time. The **interfaces** variable inherited from the Device class contains all interfaces on the switch. The interfaces on a switch only have names; they do not have MAC addresses, IP addresses, or subnet masks.
  
  
Line 204: Line 201:
  
 ===== Route Lookups ===== ===== Route Lookups =====
-Your first task is to complete the lookup(...) function in the edu.wisc.cs.sdn.vnet.rt.RouteTable class. Given an IP address, this function should return the RouteEntry object that has the longest prefix match with the given IP address. If no entry matches, then the function should return null.+Your first task is to complete the **lookup(...)** function in the **edu.wisc.cs.sdn.vnet.rt.RouteTable** class. Given an IP address, this function should return the RouteEntry object that has the longest prefix match with the given IP address. If no entry matches, then the function should return null.
  
 ===== Checking Packets ===== ===== Checking Packets =====
-Your second task is to complete the handlePacket(...) method in the edu.wisc.cs.sdn.vnet.rt.Router class to update and send a received packet out the appropriate interface of the router.+Your second task is to complete the **handlePacket(...)** method in the **edu.wisc.cs.sdn.vnet.rt.Router** class to update and send a received packet out the appropriate interface of the router.
  
-When an Ethernet frame is received, you should first check if it contains an IPv4 packet. You can use the getEtherType() method ​ in the net.floodlightcontroller.packet.Ethernet class to determine the type of packet contained in the payload of the Ethernet frame. ​ If the packet is not IPv4, you do not need to do any further processing—i.e.,​ your router should drop the packet.+When an Ethernet frame is received, you should first check if it contains an IPv4 packet. You can use the **getEtherType()** method ​ in the **net.floodlightcontroller.packet.Ethernet** class to determine the type of packet contained in the payload of the Ethernet frame. ​ If the packet is not IPv4, you do not need to do any further processing—i.e.,​ your router should drop the packet.
  
-If the frame contains an IPv4 packet, then you should verify the checksum and TTL of the IPv4 packet. You use the getPayload() method of the Ethernet class to get the IPv4 header; you will need to cast the result to net.floodlightcontroller.packet.IPv4.+If the frame contains an IPv4 packet, then you should verify the checksum and TTL of the IPv4 packet. You use the **getPayload()** method of the Ethernet class to get the IPv4 header; you will need to cast the result to **net.floodlightcontroller.packet.IPv4**.
  
-The IP checksum should only be computed over the IP header. The length of the IP header can be determined from the header length field in the IP header, which specifies the length of the IP header in 4-byte words (i.e., multiple the header length field by 4 to get the length of the IP header in bytes). The checksum field in the IP header should be zeroed before calculating the IP checksum. You can borrow code from the serialize() method in the IPv4 class to compute the checksum. If the checksum is incorrect, then you do not need to do any further processing—i.e.,​ your router should drop the packet.+The IP checksum should only be computed over the IP header. The length of the IP header can be determined from the header length field in the IP header, which specifies the length of the IP header in 4-byte words (i.e., multiple the header length field by 4 to get the length of the IP header in bytes). The checksum field in the IP header should be zeroed before calculating the IP checksum. You can borrow code from the **serialize()** method in the IPv4 class to compute the checksum. If the checksum is incorrect, then you do not need to do any further processing—i.e.,​ your router should drop the packet.
  
 After verifying the checksum, you should decrement the IPv4 packet’s TTL by 1. If the resulting TTL is 0, then you do not need to do any further processing—i.e.,​ your router should drop the packet. After verifying the checksum, you should decrement the IPv4 packet’s TTL by 1. If the resulting TTL is 0, then you do not need to do any further processing—i.e.,​ your router should drop the packet.
  
-Now, you should determine whether the packet is destined for one of the router’s interfaces. The interfaces variable inherited from the Device class contains all interfaces on the router. Each interface has a name, MAC address, IP address, and subnet mask. If the packet’s destination IP address exactly matches one of the interface’s IP addresses (not necessarily the incoming interface), then you do not need to do any further processing—i.e.,​ your router should drop the packet.+Now, you should determine whether the packet is destined for one of the router’s interfaces. The **interfaces** variable inherited from the Device class contains all interfaces on the router. Each interface has a name, MAC address, IP address, and subnet mask. If the packet’s destination IP address exactly matches one of the interface’s IP addresses (not necessarily the incoming interface), then you do not need to do any further processing—i.e.,​ your router should drop the packet.
  
 ===== Forwarding Packets ===== ===== Forwarding Packets =====
  
-IPv4 packets with a correct checksum, TTL > 1 (pre decrement), and a destination other than one of the router’s interfaces should be forwarded. You should use the lookup(...) method in the RouteTable class, which you implemented earlier, to obtain the RouteEntry that has the longest prefix match with the destination IP address. If no entry matches, then you do not need to do any further processing—i.e.,​ your router should drop the packet.+IPv4 packets with a correct checksum, TTL > 1 (pre decrement), and a destination other than one of the router’s interfaces should be forwarded. You should use the **lookup(...)** method in the RouteTable class, which you implemented earlier, to obtain the RouteEntry that has the longest prefix match with the destination IP address. If no entry matches, then you do not need to do any further processing—i.e.,​ your router should drop the packet.
  
  
-If an entry matches, then you should determine the next-hop IP address and lookup the MAC address corresponding to that IP address. You should call the lookup(...) method in the edu.wisc.cs.sdn.vnet.rt.ArpCache class to obtain the MAC address from the statically populated ARP cache. This address should be the new destination MAC address for the Ethernet frame. ​ The MAC address of the outgoing interface should be the new source MAC address for the Ethernet frame.+If an entry matches, then you should determine the next-hop IP address and lookup the MAC address corresponding to that IP address. You should call the **lookup(...)** method in the **edu.wisc.cs.sdn.vnet.rt.ArpCache** class to obtain the MAC address from the statically populated ARP cache. This address should be the new destination MAC address for the Ethernet frame. ​ The MAC address of the outgoing interface should be the new source MAC address for the Ethernet frame.
  
  
-After you have correctly updated the Ethernet header, you should call the sendPacket(...) function inherited from the edu.wisc.cs.sdn.vnet.Device class to send the frame out the correct interface.+After you have correctly updated the Ethernet header, you should call the **sendPacket(...)** function inherited from the **edu.wisc.cs.sdn.vnet.Device** class to send the frame out the correct interface.
  
 ===== Testing ===== ===== Testing =====
  
-You can test your learning switch by following the directions from Part 1. However, when starting your virtual router, you must include the appropriate static route table and static ARP cache as arguments. For example: +You can test your learning switch by following the directions from Part 1. However, when starting your virtual router, you must include the appropriate static route table and static ARP cache as arguments. For example: ​<​code>​
 java -jar VirtualNetwork.jar -v r1 -r rtable.r1 -a arp_cache java -jar VirtualNetwork.jar -v r1 -r rtable.r1 -a arp_cache
 +</​code>​
  
 You can use any of the following topologies (in the ~/​assign2/​topos directory) to test your router: You can use any of the following topologies (in the ~/​assign2/​topos directory) to test your router:
Line 249: Line 245:
 ====== Submission Instructions ====== ====== Submission Instructions ======
  
-You must submit a single tar file of the src directory containing the Java source files for your virtual switch and router. ​ Please submit the entire src directory; do not submit any other files or directories. To create the tar file, run the following command, replacing username1 and username2 with the CS username of each group member: +You must submit a single tar file of the **src** directory containing the Java source files for your virtual switch and router. ​ Please submit the entire src directory; do not submit any other files or directories. To create the tar file, run the following command, replacing ​**username1** and **username2** with the CS username of each group member: ​<​code>​
  tar czvf username1_username2.tgz src  tar czvf username1_username2.tgz src
 +</​code>​
  
 Upload the tar file to the Assignment 2 dropbox on canvas. Please submit only one tar file per group. Upload the tar file to the Assignment 2 dropbox on canvas. Please submit only one tar file per group.
assignments-s18/assignment-2-s18/start.1518645271.txt.gz · Last modified: 2018/02/14 15:54 by hyuncong