160 likes | 310 Views
Assignment #1 Overview. Computer Networks - CSC 458 Department of Computer Science. Amin Tootoonchian ( Based on slides by Clay Collier, Martin Casado , and Monia Ghobadi ). Assignment overview. You will be given a virtual network topology You write a router in C
E N D
Assignment #1 Overview Computer Networks - CSC 458 Department of Computer Science Amin Tootoonchian(Based on slides by Clay Collier, Martin Casado, and Monia Ghobadi)
Assignment overview You will be given a virtual network topology You write a router in C Your router will route real packets sent over the Internet from standard clients. Each of you has their own router, topologies, and IP addresses. Due on Fri. Oct. 19that 5 pm.
VNS • We will use Stanford University's Virtual Network System (VNS) for this and another programming assignments (http://yuba.stanford.edu/vns/) • You will receive an instruction via email by end of the weekend.
1. Student writes virtual router client 2. Packet arrives to be routed A Ethernet frames B Student’s user-space router Ethernet frames C Ethernet frames 3. Virtual router client determines outgoing interface How VNS works?
2. Virtual router “server” forwards packet to students “vr” client 3. Student’s client tells the server, which interface to route packet to Socket 1. Packet arrives destined for web server ‘C’. How it really works … VR Client Instructional machines PCLinux Firewall Internet “Virtual Router Server” Web/ftp servers
Your “vr” client establishes connection with vr server and is assigned an IP for each virtual interface • You run standard internet client (ftp) to application server A • Firewall forwards traffic with VR clients hardware address • Clientdetermines next hop and sends traffic to vr server VR Client internet How it works in excruciating detail … • Firewall sends ARP request to VR server • VR server forwards ARP request to client • VR client send ARP reply to server destined to the firewall A B “Virtual Router Server” firewall “application servers”
ARP • Why do you need ARP? • • Your routing table contains ip addresses for next hop, however • you send ethernet frames to ethernet addresses • • The web/ftp server and the router that connects you to the • internet need to know your hardware address • What you have to do: • • Generate ARP requests and parse ARP replies • • Listen to ARP requests and send ARP replies • • You don’t want to send a request for each packet, instead use • an arp cache • • Requests should time out, the arp cache as well (~15 sec)
Getting started • • Download your assigned topology file • Download the stub code from the assignment page (Upper left Corner of the page) • it handles the work required for connecting and communicating with the server. • • Compile the code and connect to the VNS server: ./sr -s vns-1.stanford.edu -t <topo-id>
… Getting started • After you connect successfully, the server will send you a description of the host including all the interfaces and their IP addresses. • The routing table is constructed from the file rtable and by default consists of only the default route which is the firewall. • You need to save your authentication key (find it in your VNS profile) in a file called auth_key which should be in the same folder as the stub code.
… Example Routing table is used to decide where to route packets
Example • To verify that you can see packets arriving to your topology, ping one of your router interfaces. • ping 172.24.74.17 • If you see output from sr that looks like: • *** -> Received packet of length 60 • *** -> Received packet of length 60 • *** -> Received packet of length 60
Forwarding in an IP router • 1. Remove IP datagram from arriving Ethernet packet. • 2. Lookup packet DA in routing table. • If known, determine next-hop IP address. • If unknown, drop packet and send ICMP message. • Internet Control Message Protocol (ICMP) • Used to send error messages. for instance, a host or router could not be reached. • 3. Decrement TTL, update header Checksum. • If TTL== 0, send ICMP message. • Time To Live (TTL): limit on the number of transmissions that a packet can experience before it should be discarded.
Forwarding in an IP router (Countinued) • 4. From next-hop IP address, determine outgoing interface and next-hop Ethernet MAC address. • If necessary, send an ARP packet to determine MAC address. • 5. Encapsulate IP datagram in Ethernet packet. • 6. Forward packet to outgoing interface.
Some hints/tips • Take a look at Clack (http://yuba.stanford.edu/vns/clack/) • • Use the “dump” option and tcpdump to examine the packets • received and forwarded by your router. • – Try ‘-v’ or even ‘-vv’ for more analysis • – Use -e to print MAC addresses • – Use -x to print out packet in hex, -xx for link layer headers • – Will detect incorrect checksums, malformed packets etc. • • Use jethereal, a graphical tool similar to tcpdump/wireshark • and it will tell you even more about what’s wrong with your • packets (http://yuba.stanford.edu/JEthereal/) • You don’t have to deal with: • – Multicast • – Broadcast • – IP Header Options
For Further Reading… • Read the assignment & FAQ • • Peek at the RFC on routers (RFC 1812) but don't worry too much about it • • For ICMP details read the RFC (RFC 792) • • If RFCs are too cryptic to read, try the RFC sourcebook at Network Sorcery: • http://www.networksorcery.com/