CSC458/2209 PA1
Simple Router
Based on slides by: Antonin & Yinan Liu
Jun Lin Chen
Get the up-to-date version from
https://www.cs.toronto.edu/~jlchen/csc458/pa1.pdf
CSC458/2209 - Computer Networks,
University of Toronto
Asking Question
• Please ask questions on Piazza.
Try not to give away any homework hints.
I will try my best to be responsive.
CSC458/2209 - Computer Networks,
University of Toronto
Overview
• Your are going to write a “simplified” router
➢ Given a static network topology
➢ Given a static routing table
➢ You are responsible for writing the logic to handle
incoming Ethernet frames (ICMP, ARP, IP….):
• Forward it
• Generate ICMP messages
• Drop it
• And more ...
CSC458/2209 - Computer Networks,
University of Toronto
But how to do it???
• Where will my routing logic run?
• Where will the traffic come from?
• How will I test my code?
CSC458/2209 - Computer Networks,
University of Toronto
• No hardware router
• Network topology emulated with Mininet:
your router connects 2 servers to a client
• Your router will handle real traffic
• The topology is emulated on CDF machines!
So please test it in our labs
CSC458/2209 - Computer Networks,
University of Toronto
Emulated Topology
CSC458/2209 - Computer Networks,
University of Toronto
Emulated Topology
CSC458/2209 - Computer Networks,
University of Toronto
Emulated Topology
CSC458/2209 - Computer Networks,
University of Toronto
What your routing logic needs to do?
• Route Ethernet frames between the client and the HTTP servers
• Handle ARP request and replies
➢ Maintain an ARP cache
• Handle traceroutes
➢ Generate TTL Exceeds Message
• Handle TCP/UDP packets sent to one of the routers’ interfaces
➢ Generate ICMP Port Unreachable
• Respond to ICMP echo requests
• See course webpage for full requirements:
http://www.cs.toronto.edu/~yganjali/courses/csc458/page-3/simple-router/
CSC458/2209 - Computer Networks,
University of Toronto
A rough flow chart
CSC458/2209 - Computer Networks,
University of Toronto
A rough flow chart
CSC458/2209 - Computer Networks,
University of Toronto
A rough flow chart
• Many things missing from this chart
➢ Checksums, TTLs
• Read the instructions carefully
• 500+ lines of code, so start early
• Submission:
• 8 time per day
• Last 7 days before the final submission
• The Markus server would give some feedback
• Final submission: Oct. 11st at 5pm
CSC458/2209 - Computer Networks,
University of Toronto
How to test your code?
• Test connectivity with ping from a server or the client
• Traceroute will not work well outside of Mininet:
➢ Use Mininet CLI
➢ mininet> server1 traceroute –n server2
• HTTP requests with wget, curl, lynx
• Don’t forget to test “error” cases!
CSC458/2209 - Computer Networks,
University of Toronto
Some advice
• Be through in your testing
• Do not hesitate to change the routing table
What about an incorrect routing table?
• Be careful when implementing Longest Prefix Match
• Don’t get mixed up with endinanness:
Linux is little endian
Network is big endian
➢ Try to put the calls to hton(), ntoh() in a single place
• Write good quality code
➢ Do not hardcode constants, avoid code duplication
Coding Guidelines
https://web.stanford.edu/class/cs244a/CS244aCodingGuidelines.html
CSC458/2209 - Computer Networks,
University of Toronto
Things that may be useful
• Mininet console, which supports:
tcpdump, ping, traceroute
(apt-get install traceroute on instance)
• Debug functions in sr_utils.c
➢ print_hdrs()
➢ print_addr_ip_int()
• GDB/Valgrind
• Tutorials Point:
http://www.tutorialspoint.com/unix_sockets/index.htm
• Pizza
CSC458/2209 - Computer Networks,
University of Toronto
Start reading!
http://www.cs.toronto.edu/~yganjali/courses/csc458/p
age-3/simple-router/
CSC458/2209 - Computer Networks,
University of Toronto