1. Homepage
  2. Programming
  3. 44100113: COMPUTER NETWORKS FALL 2023 - Project 2: Build Your Own Router

44100113: COMPUTER NETWORKS FALL 2023 - Project 2: Build Your Own Router

Engage in a Conversation
COMPUTER NETWORKS44100113Build Your Own RouterICMPARPC++PythonTsinghua

44100113-0: COMPUTER NETWORKS FALL 2023 CourseNana.COM

Build Your Own Router CourseNana.COM

Assigned: December 6, 2023 Due Date: 23:59, December 27, 2023 CourseNana.COM


You must work on this assignment individually. CourseNana.COM

This project is designed for you to: CourseNana.COM

• Learntobuildasimplerouter.
• TobefamiliarwithIPv4,ICMPandARP.

In this project, you will be writing a simple router with a static routing table. Your router will receive raw Ethernet frames and process them just like a real router: forward them to the correct outgoing interface, create new frames, etc. The starter code will provide the framework to receive Ethernet frames; your job is to create the forwarding logic. CourseNana.COM

You are allowed to use some high-level abstractions, including C++11 extensions, for parts that are not directly related to networking, such as string parsing, multi-threading, etc. CourseNana.COM

In the following contents, you will see CourseNana.COM

• DetaileddescriptionofthisporjectinSection2
• GuidelinestosetuptheenvironmentinSection3 • OverviewofthestartercodeinSection4
• SomehelpfulhintsinSections5
• HowtosubmityourcodeinSection6
• GradingcriteriainSection7

This assignment is considerably hard, so get started early, not as some of you did for FTP Project, to avoid missing the deadline. CourseNana.COM


There are four main parts in this assignment: CourseNana.COM

• HandleEthernetframes • HandleARPpackets
• HandleIPv4packets
• HandleICMPpackets

This assignment runs on top of Mininet which was built at Stanford. Mininet allows you to emulate a network topology on a single machine. It provides the needed isolation between the emulated nodes so that your router node can process and forward real Ethernet frames between the hosts like a real router. You don’t have to know how Mininet works to complete this assignment, but if you’re curious, you can learn more information about Mininet on its official website (http://mininet.org/). CourseNana.COM

Your router will route real packets between emulated hosts in a single-router topology. The project envi- ronment and the starter code has the following default topology: CourseNana.COM

+−−−−−−−−−−−−−−−−+ server1−eth0
| + +−−−−−−−−−−−+
CourseNana.COM | sw0−eth1 | +−−−−−−−−−−+ +−−−−−−−−−−−−−−−−−−+ | CourseNana.COM

| server1 | | CourseNana.COM

| |
| client |
| | | (sw0) |

| | +−−−−−−−−−−−+ | SimpleRouter | CourseNana.COM

+−−−−−−−−−−+ client −eth0 CourseNana.COM

| |
+−−−−−−−−−−−−−−−−−−+ +−−−−−−−−−−−+
CourseNana.COM + CourseNana.COM

sw0−eth3 sw0−eth2 CourseNana.COM

| server2 | |++|| CourseNana.COM

| | | +−−−−−−−−−−−+ | | | server2−eth0 CourseNana.COM

+−−−−−−−−−−−−−−−−−−−−−−+ +−−−−−−−−−−−−−−−−+ CourseNana.COM

The corresponding routing table for the SimpleRouter sw0 in this default topology: CourseNana.COM

NOTE: DonothardcodeanyIPaddresses,network,orinterfaceinformation.Wewillbetestingyour code on other single-router topologies with different number of servers and clients, and different IP and network addresses. So it is STRONGLY RECOMMENDED that you test your implementations under dif- ferentIPaddressesandroutingtables(bymodifyingthe IP_CONFIG and RTABLE filerespectively). CourseNana.COM

If your router is functioning correctly, all of the following operations should work: CourseNana.COM

Destination Gateway Mask Iface −−−−−−−−−−−− −−−−−−−−−−−− −−−−−−−−−−−−−−−− −−−−−−−− CourseNana.COM CourseNana.COM CourseNana.COM

sw0−eth3 sw0−eth1 sw0−eth2 CourseNana.COM

ping fromtheclienttoanyoftherouter’sinterfaces: CourseNana.COM

mininet> client ping CourseNana.COM

mininet> client ping

mininet> client ping

... CourseNana.COM

ping fromtheclienttoanyoftheappservers: CourseNana.COM

from the client to any of the router’s interfaces: CourseNana.COM

from the client to any of the app servers: CourseNana.COM

Downloadingfilesfromhttp-serverby wget command CourseNana.COM


mininet> client ping server1 # or client ping ... CourseNana.COM

mininet> client ping server2 # or client ping CourseNana.COM

traceroute CourseNana.COM

mininet> client traceroute ... CourseNana.COM

mininet> client traceroute CourseNana.COM

mininet> client traceroute

... CourseNana.COM

traceroute CourseNana.COM

mininet> client traceroute server1 CourseNana.COM

mininet> client traceroute server2

... CourseNana.COM

mininet> client wget<filename> CourseNana.COM

mininet> client wget<filename>

... CourseNana.COM

A data packet on a physical Ethernet link is called an Ethernet packet, which transports an Ethernet frame as its payload. CourseNana.COM

The starter code will provide you with a raw Ethernet frame. Your implementation should understand source and destination MAC addresses and properly dispatch the frame based on the protocol. CourseNana.COM

0123 01234567890123456789012345678901 +−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ CourseNana.COM

| Destination Address | + (48 bits ) +−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ CourseNana.COM

| | Source Address | +−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ (48 bits ) + || +−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ | Type (16 bits) | | CourseNana.COM

+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ + || || ~ Payload ~ || || CourseNana.COM

+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ CourseNana.COM

Note that actual Ethernet frame also includes a 32-bit Cyclical Redundancy Check (CRC). In this project, you will not need it, as it will be added automatically. CourseNana.COM

• Type : Payload types 0x0806 (ARP) CourseNana.COM

0x0800 (IPv4)
For your convenience, the starter code defines Ethernet header as an structure in :

Requirements CourseNana.COM

  • YourroutershouldignoreEthernetframesotherthanARPandIPv4. CourseNana.COM

  • Your router must ignore Ethernet frames not destined to the router, i.e., when destination hard- ware address is neither the corresponding MAC address of the interface nor a broadcast address ( FF:FF:FF:FF:FF:FF ). CourseNana.COM

  • Your router must appropriately dispatch Ethernet frames (their payload) carrying ARP and IPv4 packets. CourseNana.COM

    2.2 ARP PACKETS CourseNana.COM

    The Address Resolution Protocol (ARP) (RFC 826) is a telecommunication protocol used for resolution of Internet layer addresses (e.g., IPv4) into link layer addresses (e.g., Ethernet). In particular, before your router can forward an IP packet to the next-hop specified in the routing table, it needs to use ARP re- quest/reply to discover a MAC address of the next-hop. Similarly, other hosts in the network need to use ARP request/replies in order to send IP packets to your router. CourseNana.COM

    Note that ARP requests are sent to the broadcast MAC address ( FF:FF:FF:FF:FF:FF ). ARP replies are sent directly to the requester’s MAC address. CourseNana.COM

ethernet_hdr CourseNana.COM

core/protocol.hpp CourseNana.COM

struct ethernet_hdr { CourseNana.COM

uint8_t ether_dhost[ETHER_ADDR_LEN]; /* destination ethernet address */ CourseNana.COM

uint8_t ether_shost[ETHER_ADDR_LEN]; /* source ethernet address */ CourseNana.COM

uint16_t ether_type ; /* packet type ID */ } __attribute__ ((packed)) ; CourseNana.COM

0123 01234567890123456789012345678901 +−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ CourseNana.COM

| Hardware Type | Protocol Type | +−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ CourseNana.COM

| HW addr len | Prot addr len | Opcode | +−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ || ~ Source hardware address ~ || +−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ CourseNana.COM

|| ~ Source protocol address ~ || +−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ || CourseNana.COM

~ Destination hardware address ~ || +−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ || ~ Destination protocol address ~ || CourseNana.COM

+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ CourseNana.COM

struct arp_hdr CourseNana.COM

arp_hdr CourseNana.COM

core/protocol.hpp CourseNana.COM

unsigned unsigned unsigned unsigned unsigned CourseNana.COM

short short char char short CourseNana.COM

arp_hrd ; arp_pro ; arp_hln ; arp_pln ; arp_op ; CourseNana.COM

/* format of hardware address */ /* format of protocol address */ /* length of hardware address */ /* length of protocol address */ /* ARP opcode (command) */ CourseNana.COM

unsigned char CourseNana.COM

uint32_t CourseNana.COM

unsigned char CourseNana.COM

arp_sha[ETHER_ADDR_LEN]; /* sender hardware address arp_sip ; / * sender IP address arp_tha[ETHER_ADDR_LEN]; /* target hardware address arp_tip ; /* target IP address CourseNana.COM

*/ * / */ */ CourseNana.COM

} __attribute__ ((packed)) ;

Requirements CourseNana.COM

  • YourroutermustproperlyprocessincomingARPrequestsandreplies: CourseNana.COM

    • –  MustproperlyrespondtoARPrequestsforMACaddressfortheIPaddressofthecorrespond- ing network interface CourseNana.COM

    • –  MustignoreotherARPrequests CourseNana.COM

  • When your router receives an IP packet to be forwarded to a next-hop IP address, it should check CourseNana.COM

    ARP cache if it contains the corresponding MAC address: CourseNana.COM

    • –  Ifavalidentryfound,theroutershouldproceedwithhandlingtheIPpacket CourseNana.COM

    • –  Otherwise,theroutershouldqueuethereceivedpacketandstartsendingARPrequesttodis- cover the IP-MAC mapping. CourseNana.COM

  • When router receives an ARP reply, it should record IP-MAC mapping information in ARP cache (Source IP/Source hardware address in the ARP reply). Afterwards, the router should send out all corresponding enqueued packets. CourseNana.COM

    NOTE: Your implementation should not save IP-MAC mapping based on any other messages, only from ARP replies! CourseNana.COM

  • ToreducestalenessoftheARPinformation,entriesinARPcacheshouldtimeoutafter 30seconds. Thestartercode(ArpCache class)alreadyincludesthefacilitytomarkARPentries“invalid”.Your task is to remove such entries. If there is an ongoing traffic (e.g., client still pinging the server), then the router should go through the standard mechanism to send ARP request and then cache the response. If there is no ongoing traffic, then ARP cache should eventually become empty. CourseNana.COM

  • TheroutershouldsendanARPrequestaboutonceaseconduntilanARPreplycomesbackorthe requesthasbeensentoutatleast 5times. CourseNana.COM

    If your router didn’t receive ARP reply after re-transmitting an ARP request 5 times, it should stop re-transmitting, remove the pending request, and any packets that are queued for the transmission that are associated with the request. CourseNana.COM

    YourroutershouldalsosendanICMPDestination HostUnreachable messagetothesourceIP. CourseNana.COM

    2.3 IPV4 PACKETS CourseNana.COM

    Internet Protocol version 4 (IPv4) (RFC 791) is the dominant communication protocol for relaying data- grams across network boundaries. Its routing function enables internetworking, and essentially estab- lishes the Internet. IP has the task of delivering packets from the source host to the destination host solely based on the IP addresses in the packet headers. For this purpose, IP defines packet structures that encapsulate the data to be delivered. It also defines addressing methods that are used to label the datagram with source and destination information. CourseNana.COM

0123 01234567890123456789012345678901 +−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ CourseNana.COM

| Version | IHL | Type of Service | Total Length | +−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ CourseNana.COM

| Identification | Flags | Fragment Offset | +−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ | Time to Live | Protocol | Header Checksum | +−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ | Source Address | CourseNana.COM

+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ | Destination Address | +−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ | Options | Padding | +−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ || CourseNana.COM

|| ~ Payload ~ || || +−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ CourseNana.COM

For your convenience, the starter code defines the IPv4 header as an structure in : CourseNana.COM

uint8_t uint16_t CourseNana.COM

ip_tos ; ip_len ; CourseNana.COM

service */ CourseNana.COM

core/protocol.hpp CourseNana.COM

struct ip_hdr { CourseNana.COM

unsigned int ip_hl :4; unsigned int ip_v :4; CourseNana.COM

/* header
* version
* type of
* total length */ CourseNana.COM

length */ CourseNana.COM

uint16_t uint16_t
uint16_t ip_sum;

/* identification */
* fragment offset field */ /* time to live */
* protocol */
* checksum * / CourseNana.COM

ip_id ; CourseNana.COM

ip_off ; ip_ttl ; ip_p ; CourseNana.COM

uint32_t ip_src , ip_dst ; /* source and dest address */ } __attribute__ ((packed)); CourseNana.COM

Requirements CourseNana.COM

  • ForeachincomingIPv4packet,yourroutershouldverifyitschecksumandtheminimumlengthof an IP packet CourseNana.COM

    Invalidpacketsmustbediscarded. CourseNana.COM

  • Your router should classify datagrams into (1) destined to the router (to one of the IP addresses of CourseNana.COM

    the router), and (2) datagrams to be forwarded: CourseNana.COM

    For(1),ifpacketcarriesICMPpayload,itshouldbeproperlydispatched.Otherwise,discarded (a proper ICMP error response is NOT required for this project). CourseNana.COM

    For (2), your router should use the longest prefix match algorithm to find a next-hop IP ad- dress in the routing table and attempt to forward it there CourseNana.COM

  • For each forwarded IPv4 packet, your router should correctly decrement TTL and recompute the checksum. CourseNana.COM


Internet Control Message Protocol (ICMP) (RFC 792) is a simple protocol that can send control informa- tion to a host. CourseNana.COM

In this assignment, your router will use ICMP to send messages back to a sending host. • Echo or message CourseNana.COM

Echo Reply CourseNana.COM

0123 CourseNana.COM

01234567890123456789012345678901 +−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ | Type | Code = 0 | Checksum | +−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ CourseNana.COM

| Identifier | Sequence Number | CourseNana.COM

+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ | Data ... CourseNana.COM

+−+−+−+−+− CourseNana.COM

Type CourseNana.COM

8 : echo message
0 : echo reply message

message CourseNana.COM

Time Exceeded CourseNana.COM

0123 CourseNana.COM

01234567890123456789012345678901 +−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ | Type=11 | Code | Checksum | +−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ CourseNana.COM

| unused | +−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ | Internet Header + 64 bits of Original Data Datagram | +−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ CourseNana.COM

Code CourseNana.COM

0 : time to live exceeded in transit
1 : fragment reassembly time exceeded (NOT required to implement)

message CourseNana.COM

Destination Unreachable CourseNana.COM

0123 CourseNana.COM

01234567890123456789012345678901 +−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ CourseNana.COM

| Type=3 | Code | Checksum | +−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ | unused | +−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ | Internet Header + 64 bits of Original Data Datagram | +−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+−+ CourseNana.COM

Code CourseNana.COM

  • *  1 : Destination host unreachable CourseNana.COM

  • *  3 : Destination port unreachable CourseNana.COM

    When an ICMP message is composed by a router, the source address field of the internet header can be the IP address of any of the router’s interfaces, as specified in RFC 792. CourseNana.COM

    Notethat TimeExceeded messageisneededfor traceroute toworkproperly.
    For your convenience, the starter code defines the ICMP header as an structure in :

    You may want to create additional structs for ICMP messages, but make sure to use the packed attribute so that the compiler doesn’t try to align the fields in the struct to word boundaries (i.e., must use CourseNana.COM

    __attribute__((packed)) annotation). CourseNana.COM

    Requirements CourseNana.COM

    Your router should properly generate the following ICMP messages, including proper ICMP header check- sums: CourseNana.COM

icmp_hdr CourseNana.COM

core/protocol.hpp CourseNana.COM

struct icmp_hdr { uint8_t icmp_type ; uint8_t icmp_code; CourseNana.COM

uint16_t icmp_sum;
} __attribute__ ((packed));

Echo Reply message ( type 0 ):
Sent in response to an incoming
Echo Request message (ping) to one of the router’s interfaces. CourseNana.COM

Echo requests sent to other IP addresses should be forwarded to the next hop address as usual. Inthisproject, EchoReply message’sinitialTTLfieldinitsIPv4headershouldbe 64. CourseNana.COM

Time Exceeded message ( type 11 , code 0 ):
Sent if an IP packet is discarded during processing because the TTL field is 0. This is needed for

traceroute to work.
Port Unreachable message ( type 3 , code 3 ): CourseNana.COM

Sent if an IP packet containing a UDP or TCP payload is sent to one of the router’s interfaces. This is needed for traceroute to work. CourseNana.COM


You are suggested to finish this project on Ubuntu 16.04.7. If your system is Windows or Mac OS, you can install Ubuntu 16.04.7 Virtual Machine in VMware. (Do not use Windows Subsystem for Linux (WSL), as Mininet is currently not supported by WSL.) CourseNana.COM

We provide to setup the environment. Please run it in superuser mode: CourseNana.COM

setup.sh CourseNana.COM

sudo bash setup.sh CourseNana.COM

To run or test your code, please change work path to the project directory and open three terminals here, then CourseNana.COM

  1. inthefirstterminal,startpox CourseNana.COM

    /opt/pox/pox . py −−verbose ucla_cs118 CourseNana.COM

  2. inthesecondterminal,startMininet chmod +x run.py CourseNana.COM

    sudo ./run.py CourseNana.COM

    To exit Mininet, type exit command in this terminal. CourseNana.COM

3. inthethirdterminal,startyourrouter CourseNana.COM

Besides,youcanusethe show-arp.py scripttoprintoutyourrouter’scurrentarpcacheorroutingtable in another terminal. CourseNana.COM

• Toshowarpcahce,run: CourseNana.COM

./show−arp.py arp CourseNana.COM

• Toshowroutingtable,run: CourseNana.COM

./show−arp.py routing CourseNana.COM

Here are some tips: CourseNana.COM

./ router

Got packet of size 42 on interface sw0−eth1 CourseNana.COM

Received packet, but interface is unknown, ignoring CourseNana.COM

Resetting SimpleRouter with 0 ports CourseNana.COM

Interface l i s t empty CourseNana.COM

/usr/bin/env: ’python\r ’ : No such file or directory CourseNana.COM

sudo apt−get install dos2unix dos2unix run.py CourseNana.COM

• • CourseNana.COM

When POX controller is restrated, the simpler router needs to be manually stopped and started again. CourseNana.COM

Ifyougetthefollowingoutputsafterrunning or CourseNana.COM

Try cleaning up mininet related environments by CourseNana.COM

sudo mn −c CourseNana.COM

4 STARTER CODE OVERVIEW is the overal structure of the starter code: CourseNana.COM

simple−router .hpp
+−−−−−−−−−−−−−−+ core/protocol .hpp

| SimpleRouter | core/ utils .hpp

|| +−−−+−−−−−+−−−−+ CourseNana.COM

m_arp 1 | 1| | 1 m_ifaces +−−−−−−−−−−−−−−−−+ | +−−−−−−−−−−−−−−−−−−+ ||| CourseNana.COM

| | m_routingTable | |||
|1 |1 | N (std::set)

vvv +−−−−−−+−−−−−+ +−−−−−−+−−−−−−−+ +−−−−−+−−−−−+ |||||| CourseNana.COM

| ArpCache | | RoutingTable | | Interface | |||||| +−−−−−−−−−−−−+ +−−−−−−−−−−−−−−+ +−−−−−−−−−−−+ CourseNana.COM

arp−cache.hpp routing−table .hpp core/interface .hpp CourseNana.COM

Mainclassforyoursimplerouter,encapsulating ArpCache, RoutingTable,andassetof Interface CourseNana.COM

objects. CourseNana.COM

Class containing information about router’s interface, including router interface name ( name ), CourseNana.COM

hardware address ( addr ), and IPv4 address ( ip ). CourseNana.COM

RoutingTable ( routing-table.hpp|cpp )
Class implementing a simple routing table for your router. The content is automatically loaded

fromatextfilewithdefaultfilenameis RTABLE (namecanbechangedusing RoutingTable option in router.config configfile) CourseNana.COM

ArpCache ( arp-cache.hpp|cpp ) CourseNana.COM

Exception : Error creating interface . . . RTNETLINK answers : File exists CourseNana.COM

autograde.py CourseNana.COM

Method to send raw Ethernet frames ( CourseNana.COM

Method to handle ARP cache events ( CourseNana.COM

Method to lookup entry in the routing table ( CourseNana.COM

Class for handling ARP entries and pending ARP requests. CourseNana.COM

4.1 KEY METHODS CourseNana.COM

Your router receives a raw Ethernet frame and sends raw Ethernet frames when sending a reply to the sending host or forwarding the frame to the next hop. The basic functions to handle these functions are: CourseNana.COM

Method that receives a raw Ethernet frame ( CourseNana.COM

Need to implement CourseNana.COM

Implemented CourseNana.COM

simple-router.hpp|cpp CourseNana.COM

* This method is called each time the router receives a packet on CourseNana.COM

* the interface. The packet buffer \p packet and the receiving CourseNana.COM

* interface \p inIface are passed in as parameters. CourseNana.COM

*/ CourseNana.COM

SimpleRouter::handlePacket(const Buffer& packet, const std::string& inIface); CourseNana.COM

simple-router.hpp|cpp CourseNana.COM

* Call this method to send packet \p packt from the router on CourseNana.COM

* interface \p outIface CourseNana.COM

*/ CourseNana.COM

SimpleRouter::sendPacket(const Buffer& packet, const std::string& outIface); CourseNana.COM

Need to implement CourseNana.COM

arp-cache.hpp|cpp CourseNana.COM

* This method gets called every second. For each request sent out, CourseNana.COM

* you should keep checking whether to resend a request or remove it. CourseNana.COM

*/ CourseNana.COM

void CourseNana.COM

ArpCache : : periodicCheckArpRequestsAndCacheEntries ( ) ; CourseNana.COM

Need to implement CourseNana.COM

routing-table.hpp|cpp CourseNana.COM

* This method should lookup a proper entry in the routing table CourseNana.COM

* using " longest −prefix match" algorithm CourseNana.COM

*/ CourseNana.COM

RoutingTable : : lookup ( uint32_t ip )
const ; CourseNana.COM


We have provided you with some basic debugging functions in core/utils.hpp ( core/utils.cpp ). Feel free to use them to print out network header information from your packets. Below are some functions you may find useful: CourseNana.COM

print_hdrs(const uint8_t *buf, uint32_t length) , print_hdrs(const Buffer& packet) Print out all possible headers starting from the Ethernet header in the packet CourseNana.COM

ipToString(uint32_t ip) , ipToString(const in_addr& address)
Print out a formatted IP address from a uint32_t or in_addr . Make sure you are passing the IP CourseNana.COM

address in the correct byte ordering CourseNana.COM

macToString(const Buffer& macAddr) PrintoutaformattedMACaddressfroma Buffer ofMACaddress CourseNana.COM


You can use Mininet to monitor traffic that goes in and out of the emulated nodes, i.e., router, server1 and server2. For example, to see the packets in and out of server1 node, use the following command in Mininet command-line interface (CLI): CourseNana.COM

mininet> server1 sudo tcpdump −n −i server1−eth0 CourseNana.COM

Alternatively, you can bring up a terminal inside server1 using the following command CourseNana.COM

mininet> xterm server1 CourseNana.COM

then inside the newly opened : CourseNana.COM

$ sudo tcpdump −n −i server1−eth0 CourseNana.COM


Toeasedebugging,wemakeasimplifiedversionofgradingscriptpublicwith autograde.py.Itcontains all the public test cases (details in Section 7), which make up 45/85 of the total test score. To run the script, first start pox and your router, then use the following command: CourseNana.COM

chmod +x autograde.py sudo . / autograde . py CourseNana.COM

The grading result and related information will be shown in standard output as well as the details.log file. You can also change the logging level to see more detailed information: CourseNana.COM

log . setLevel ( logging .DEBUG) CourseNana.COM

If you get the following outputs from router: CourseNana.COM

Just turn off your router, grading script, and then start and exit Mininet with run.py . Afterwards, the grading script may work as expected. CourseNana.COM

Got packet of size 42 on interface sw0−eth1 Received packet, but interface is unknown, ignoring CourseNana.COM

Notice that the private, comprehensive grading script will be run on other single-router topology with different interfaces, IP/MAC addresses. Thus, the output of provided script may be different from your final score, even on public test cases. CourseNana.COM


Given a raw Ethernet frame, if the frame contains an IP packet that is not destined towards one of our interfaces: CourseNana.COM

  • Sanity-checkthepacket(meetsminimumlengthandhascorrectchecksum). CourseNana.COM

  • DecrementtheTTLby1,andrecomputethepacketchecksumoverthemodifiedheader. CourseNana.COM

  • Find out which entry in the routing table has the longest prefix match with the destination IP ad- dress. CourseNana.COM

  • Check the ARP cache for the next-hop MAC address corresponding to the next-hop IP. If it’s there, send it. Otherwise, send an ARP request for the next-hop IP (if one hasn’t been sent within the last second), and add the packet to the queue of packets waiting on this ARP request. CourseNana.COM

    If an incoming IP packet is destined towards one of your router’s IP addresses, you should take the fol- lowing actions, consistent with the section on protocols above: CourseNana.COM

  • If the packet is an ICMP echo request and its checksum is valid, send an ICMP echo reply to the sending host. CourseNana.COM

  • IfthepacketcontainsaTCPorUDPpayload,sendanICMPportunreachabletothesendinghost. Otherwise, ignore the packet. Packets destined elsewhere should be forwarded using your normal forwarding logic. CourseNana.COM

    Obviously, this is a very simplified version of the forwarding process, and the low-level details follow. For example, if an error occurs in any of the above steps, you will have to send an ICMP message back to the sender notifying them of an error. You may also get an ARP request or reply, which has to interact with the ARP cache correctly. CourseNana.COM

    In case you have difficulties, you can contact the TAs by email: zgxw18@gmail.com,ycdfwzy@outlook.com or visit the TAs at 11-211, East Main Building. CourseNana.COM


    To submit your project, you need to prepare: CourseNana.COM

  1. A report.pdf filenomorethanTHREEpages.(Seedetailsinsection7) CourseNana.COM

  2. Allyoursourcecode, Makefile and report.pdf asa .tar.gz archive(andanyfilesfromextracredit part). CourseNana.COM

    To create the submission, use the provided Makefile in the starter code. Just update Makefile to include your student ID and then just type CourseNana.COM

    make tarball CourseNana.COM

Then submit the resulting archive to WEB LEARNING. Before submission, please make sure: CourseNana.COM

• • • CourseNana.COM

Yourcodecompiles Yourimplementationconformstothespecification CourseNana.COM

.tar.gz archivedoesnotcontaintemporaryorotherunnecessaryfiles.Wewillautomaticallydeduct points otherwise. CourseNana.COM


Yourprojectwillbegradedbasedonthefollowingparts(privatetestsarenotprovidedin autograde.py): 1. Pingtests CourseNana.COM

  1. a)  (5 pts, public) Pings from client to all other hosts (all pings expected to succeed), including non-existing host (error expected) CourseNana.COM

  2. b)  (5 pts, public) Pings from server1 to all other hosts (all pings expected to succeed), including non-existing host (error expected) CourseNana.COM

  3. c)  (5 pts, public) Pings from server2 to all other hosts (all pings expected to succeed), including non-existing host (error expected) CourseNana.COM

  4. d)  (10pts,private)Pingresponses(fromclient)haveproperTTLs CourseNana.COM

  5. e)  (5pts,public)Pingbetweenselectedhosts,checkARPcache,thereshouldbeapropernum- ber of entries CourseNana.COM

  6. f)  (5pts,public)Pingfromclienttoserver1,after40seconds,theARPcacheshouldbeempty(+ no segfaults) CourseNana.COM

  7. g)  (5 pts, private) Ping from client a non-existing IP, router sends proper ARP requests (+ no segfaults) CourseNana.COM

  8. h)  (5pts,private)Pingfromclient,receivehostunreachablemessage CourseNana.COM

2. Traceroutetests CourseNana.COM

a) (5pts,public)Traceroutefromclienttoallotherhosts,includinganon-existinghost b) (5pts,public)Traceroutefromserver1toallotherhosts,includinganon-existinghost c) (5pts,public)Traceroutefromserver2toallotherhosts,includinganon-existinghost CourseNana.COM

d) (10pts,private)Traceroutefromclienttorouter’sinterfaces(get1line) 3. Filedownloadingtests CourseNana.COM

a) (5pts,public)Downloadasmallfile(1KB)fromanyserverthroughhttp CourseNana.COM

b) (10pts,private)Downloadalargefile(10MB)fromanyserverthroughhttp 4. (20pts)CodequalityandProjectReport(report.pdf) CourseNana.COM


The project report could include: CourseNana.COM

a) YournameandstudentID
b) Theproblemsyouhavemetinthisprojectandhowyousolvedthem.

c) Listofanyadditionallibrariesused. d) Anyadviceonthisproject. CourseNana.COM

Note that poor design, code structure, or report will probably reduce the credits you gained in this part. CourseNana.COM

Suppose you get A credits according to the above criteria, your final grade should be CourseNana.COM

This project is based on the CS118 class project by Alexander Afanasyev, UCLA. CourseNana.COM

Get in Touch with Our Experts

Wechat WeChat
Whatsapp Whatsapp
COMPUTER NETWORKS代写,44100113代写,Build Your Own Router代写,ICMP代写,ARP代写,C++代写,Python代写,Tsinghua代写,COMPUTER NETWORKS代编,44100113代编,Build Your Own Router代编,ICMP代编,ARP代编,C++代编,Python代编,Tsinghua代编,COMPUTER NETWORKS代考,44100113代考,Build Your Own Router代考,ICMP代考,ARP代考,C++代考,Python代考,Tsinghua代考,COMPUTER NETWORKShelp,44100113help,Build Your Own Routerhelp,ICMPhelp,ARPhelp,C++help,Pythonhelp,Tsinghuahelp,COMPUTER NETWORKS作业代写,44100113作业代写,Build Your Own Router作业代写,ICMP作业代写,ARP作业代写,C++作业代写,Python作业代写,Tsinghua作业代写,COMPUTER NETWORKS编程代写,44100113编程代写,Build Your Own Router编程代写,ICMP编程代写,ARP编程代写,C++编程代写,Python编程代写,Tsinghua编程代写,COMPUTER NETWORKSprogramming help,44100113programming help,Build Your Own Routerprogramming help,ICMPprogramming help,ARPprogramming help,C++programming help,Pythonprogramming help,Tsinghuaprogramming help,COMPUTER NETWORKSassignment help,44100113assignment help,Build Your Own Routerassignment help,ICMPassignment help,ARPassignment help,C++assignment help,Pythonassignment help,Tsinghuaassignment help,COMPUTER NETWORKSsolution,44100113solution,Build Your Own Routersolution,ICMPsolution,ARPsolution,C++solution,Pythonsolution,Tsinghuasolution,