IP/TCP Network Stack
An IP/TCP stack made from scratch
Overview

RFC compliant user-level IP/TCP stack implemented completely from scratch. It operates over a simulated link layer (UDP-based virtual network) and supports parsing and running various network topologies with the demo using this more complex loop topology:

Using the custom REPL, a user can listen, connect, and close sockets, send and receive packets from simple messages to large texts and images, set a custom packet drop/loss rate, simulate link failures by disabling interfaces, and view tabled information about a node (host/router). And of course, everything can be analyzed on Wireshark.

IP Layer Functionality
The IP layer is capable of forwarding IP packets as well as handling parsing and serialization of IPv4 headers, calculating IP checksums, and tracking TTL. Distance-vector routing is implemented based on RIP protocol. Routing loop prevention is implemented using Split Horizon with Poison Reverse. Routing entries expire if a neighbor failed to refresh them thus keeping the routing table updated with the state of the network (i.e. network partitions, offline routers).
TCP Layer Functionality
The TCP layer implements a custom socket API supporting standard network application commands (Connect, Listen, Accept, Send, Receive, and Close). The stack follows the TCP connection lifecycle including the 3-way handshake for connection setup, teardown, and synchronized state transitions:

Flow control is implemented with the sliding window protocol including Zero Window Probing. TCP packet reordering (out-of-order queueing) is handled with an early arrival queue. TCP packet retransmission is handled with a retransmission queue using Smoothed Round-Trip-Time (SRTT) to update Retransmission Timeouts (RTO) for automatic retransmission of lost or dropped packets. An event-driven design is used to avoid busy-waiting.
Technical Notes
Implemented in Go (Golang), interfaced with tmux, and analyzed with Wireshark. Took around 80-100 hours.