{"id":15732247,"url":"https://github.com/alexhff/minirouter","last_synced_at":"2025-07-31T02:05:57.971Z","repository":{"id":110550546,"uuid":"171024719","full_name":"AlexHff/minirouter","owner":"AlexHff","description":"Simple router given a static network topology and routing table.","archived":false,"fork":false,"pushed_at":"2019-02-16T16:38:24.000Z","size":489,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-06T08:13:00.378Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlexHff.png","metadata":{"files":{"readme":"README.txt","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-16T16:25:51.000Z","updated_at":"2023-01-31T18:30:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"0ed2927c-3bb6-4025-b5be-0346f7c29067","html_url":"https://github.com/AlexHff/minirouter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexHff%2Fminirouter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexHff%2Fminirouter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexHff%2Fminirouter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexHff%2Fminirouter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlexHff","download_url":"https://codeload.github.com/AlexHff/minirouter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246409700,"owners_count":20772534,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-04T00:08:45.021Z","updated_at":"2025-03-31T03:25:34.897Z","avatar_url":"https://github.com/AlexHff.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"Name: Alexander Hoffmann\nPID: U08115448\n\nI am not competing for the Espresso prize.\n\nRequired Functionality\n\n    The router must successfully route packets between the Internet and the application \nservers.\n    The method sr_handle_forwarding() in sr_handlepacket_ip.c routes any type of packet from \nthe client to one of the hosts. To find the destination, we get the routing table from the \ncurrent instance and compute the LPM. Then, get the sender interface and the arpcache to find \nif we already have the MAC address of our next hop. If we have, modify the header and send \npacket. If we don't have, we go to handle_arpreq() which will send an ARP request to the next \nhop.\n    \n    The router must correctly handle ARP requests and replies.\n    When we get a packet, check if it's ARP type. Then verifiy what kind or ARP. If ARP \nrequest, then sr_handlepacketÃ_arp_request() in sr_handlepacket_arp.c will create a new reply \npacket with the MAC address of the current interface. If it's an ARP reply, we check the \nqueue associated to the request we sent earlier. After that, we send every packet of the \nqueue respecting the FIFO principle. This was probably one of the hardest parts because it \nwasn't clear how the packets were added to the queue. It turns out it's a stack following \nLIFO principle. Therefore, I had to create an array inversing every element of the stack to \nsend out the packets in the correct order.\n\n    The router must correctly handle traceroutes through it (where it is not the end host) \nand to it (where it is the end host).\n    Traceroute was definitely the most complexe aspect of the project. The first step is to \nsend an ICMP TTL exceeded for the first packet received. This is implmented in \nsr_handlepacket_ip.c. If the TTL is good, forward the packet. Now we need to check if the MAC \naddress of the next hop is in our ARP cache. If it is, just send the packet, change eth hdr. \nIf it's not, we have to store the packet in a stack and send an ARP request to the correct \nIP. When the ARP reply comes back, we can handle all the packet in the queue. Now since the \nqueue is a stack, we first need to convert it into an array to access the first element that \ngot to the router. Indeed, we need to respect the FIFO principle. All of this is implemented \nin sr_handle_forwarding in sr_handlepacket_ip.c and in sr_arpcache.c. The header was very \nhelpful since it gave pseudo-code for the implementation of some methods.\n\n    The router must respond correctly to ICMP echo requests.\n    ICMP echo request are directed to the router. In this case, we just check that the packet \nis good hence the ip header checksum is correct and the icmp type and code is good, then we \ntake that same packet and modify element in the header and send it back.\n\n    The router must handle TCP/UDP packets sent to one of its interfaces. In this case the \nrouter should respond with an ICMP port unreachable.\n    For this, just check the type of IP and if it's for the router. If both this conditions \nare valid, verify that the packet is not corrupted by computing the checksum of the ip \nheader. If everything is good, we just create a new ICMP packet in the method \nsr_handlepacket_tcp_udp(). Here, we just create an ICMP host unreachable packet for the \nsource of the UDP/TCP packet.\n\n    The router must maintain an ARP cache whose entries are invalidated after a timeout \nperiod (timeouts should be on the order of 15 seconds).\n    All the methods related to the ARP cache are implemented in sr_arpcache.c. Here I just \nconverted the pseudo-code given in the header into C code.\n\n    The router must queue all packets waiting for outstanding ARP replies. If a host does not \nrespond to 5 ARP requests, the queued packet is dropped and an ICMP host unreachable message \nis sent back to the source of the queued packet.\n    See previous requirement.\n\n    The router must not needlessly drop packets (for example when waiting for an ARP reply)\n    All the packets are stored in a queue if they can not be sent out immediately.\n\n    The router must enforce guarantees on timeouts--that is, if an ARP request is not \nresponded to within a fixed period of time, the ICMP host unreachable message is generated \neven if no more packets arrive at the router. (Note: You can guarantee this by implementing \nthe sr_arpcache_sweepreqs function in sr_arpcache.c correctly.)\n    \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexhff%2Fminirouter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexhff%2Fminirouter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexhff%2Fminirouter/lists"}