
Develop and implement an end-to-end network protocol in C on Linux, preparing you for industry work by mastering protocol design, debugging, and feature integration, with strict prerequisites.
Explore theory and implementation of a simplified interior gateway routing protocol in C, covering adjacency management, building a link-state database, SPF-based route computation, and testing practices.
Follow a three-phase roadmap to build a tcp ip stack protocol: schooling, college, and working professionally, covering hands-on library use, theory, and development to implement and troubleshoot the interrogation protocol.
Discover how to plan, set up, and implement a network protocol in C from scratch. Follow theory, complete assignments, and use GitHub and debugging tools to master phase one.
Download the source code from the GitHub repository and compile the TCP/IP stack, using the cheat sheet to malac an internet packet with data-link and IP header APIs.
Set up Source Insight on Windows, download and license the tool, import the TCP IP stack read-only project, and explore function call relationships to boost navigation speed.
Note : file testapp.c has been renamed as main.c
Explore show topology outputs for L3 routers, verify interface status and neighbors, note the IP addresses and randomly assigned MACs, and inspect routing and ARP tables with built-in commands.
Capture and debug network traffic by logging packets sent and received with the tcp/ip stack library, enabling device and interface logs to inspect IP, ARP, and ICMP headers.
Explore the internal design of the pebbled tcp/ip stack from physical to application layers and learn to build application-layer protocols atop it without socket programming.
Register for interface configuration change events during initialization and have the application layer react to admin changes, updating hello packets and other protocols that rely on the interface.
Explore how the Libcli library enables CLI interaction with a TCP/IP stack library through Lipgloss, adding custom commands to configure and debug the application-layer protocol.
Welcome students to college life and outline building an interior gateway protocol from scratch, covering adjacency management, linkstar state database, and the SBF algorithm.
Learn how l3 routing tables are constructed to forward traffic along the shortest, loop-free paths using link costs and equal-cost multipath, coordinating routers to avoid loops.
Outline the goals and problem statement: given a network graph of P2P links with costs, compute each node's routing table that reaches every loopback address using shortest paths.
Explore the format of a routing table entry, including destination IP, outgoing interface, gateway, and cost, and learn how topology changes trigger recomputation for optimal routing.
Explore how ECMP enables routers to forward traffic across multiple equal-cost paths, using routing table entries with multiple next hops to distribute load toward gateways.
Build a local input graph on each device that mirrors the physical topology, including IP addresses and interface details. Apply the algorithm on this graph to compute the routing table.
This lecture shows how a routing table entry for destination 192.168.0.2 (router B's loopback) is built, using next hop, gateway IP, and local entries to forward toward the next hop.
Learn how a physical topology is represented as a graph in router memory. Explore the three-phase process and the dicastery algorithm to derive a loop-free routing table via shortest paths.
Construct the input graph from a physical network topology by devices exchanging hello packets to learn neighbors, building naval ship databases, flooding membership databases, and forming a cumulative network graph.
Routers exchange hello packets between directly connected neighbors to build the neighbor ship database, recording each neighbor's name, interface, IP address, and loopback in the three-device topology.
Flood all routers with link state packets to share their local topology databases, enabling every router to build a graph and converge on a common link state database for routing.
Run the shortest path first algorithm on each routing device's local link-state database, using the phase one input graph to derive per-device shortest paths for phase three routing table computation.
Apply the SPF algorithm on a graph to compute shortest paths from a source node. Initialize distances, relax neighbors via a priority queue, and record results.
Apply phase two SPF rules to explore edges, update next hops when x+m<y, union on equal costs, and stop when the priority queue empties.
Apply the spf algorithm to a sample input graph, updating shortest paths from the source via a priority queue and recording next hops and costs, including equal-cost paths.
Phase 3 computes the routing table from phase two's output produced by the sbf algorithm, replacing destination names with loopback addresses for node s with minimum-cost reachability under scmp constraints.
Conclude the section by translating protocol theory into action, outlining steps to integrate the protocol into a TCP/IP stack and related libraries, and planning a phased internal logic implementation.
Begin implementing the protocol by bringing it to life through minimal, barely breathing exercises in a new application on the application layer of the tcp/ip stack library.
Explore how a robust ecosystem of libraries, build systems, testing infrastructure, and technology stack enables developing a network protocol at the application layer.
Introduce the libcli concept using the pre-integrated Lipgloss library in the tcap stack for fast, resource-light cli on embedded devices, and complete appendix e parts 1 and 2.
Develop the Isis CLI by creating new source files, updating the Makefile in the TCP/IP stack, and wiring a back-end handler to enable or disable the protocol on a node.
Develop and test a cli backend handler by parsing the command code, extracting the node name, and enabling or disabling the protocol based on positive or negative inputs.
Define protocol configuration holders as data structures that store device-level and interface-level configurations, then extend device and interface properties and create two header files in the ISIS directory.
Develop a show cli to display the protocol state, verify enabling or disabling the protocol via the config cli, and ensure internal data structures reflect the changes.
Learn to enable or disable the ISIS protocol at an interface level, extending the CLI to support interface keywords, and enforce device-wide versus per-interface rules for consistent configuration.
Implement a cli-based interface configuration flow by adding an interface name leaf, parsing user input, retrieving the interface by name, and enabling or disabling protocols on the interface via APIs.
Implement enable and disable operations for the protocol on interfaces, ensuring node-level activation precedes interface activation and applying changes across all interfaces via a looping macro.
design a simplified protocol packet format encapsulated in an ethernet frame, defining hollow (hello) and link state packets, with a fixed 131 type, broadcast destination, zero checksum, and payload rules.
Learn to manipulate ethernet frames with the tcp/ip stack library APIs, create and free packets, access internet headers and payloads, and manage mac addresses and broadcast checks.
Learn how packet registration routes ISIS packets to the correct application by defining a packet classification rule and installing it at layer two or layer three, using socket APIs.
Implement a protocol receive function and register a packet drop rule using the packet classification rule so the data link layer forwards classified packets to the protocol.
Learners prepare to begin the core protocol development, starting with adjacency management as phase one, and explore enabling interface event notifications through the TCP/IP stack ecosystem.
Begin the core development of the protocol by implementing adjacency management, sending hello packets to neighbors, processing received packets, and updating neighbor information to integrate with the TCP/IP stack library.
Examine how halo (hello) packets are exchanged between routers, detailing the halo content such as loopback address, device host name, interface IP, interface index, time and cost for neighbor discovery.
Define and implement an ISIS adjacency data structure that stores neighbor loopback address, neighbor name, interface IP address, interface index, hold time, cost, uptime, and adjacency state from hello packets.
Model the adjacency state machine for network protocols, with down, init, and up states. Use hello packets and timeouts to move from down to init to up.
Introduce and manage adjacency using two timers: a delete timer and an expiry timer, to control adjacency lifetime and transitions in the ISIS adjacency state, using the timer sub library.
Learn to implement hello packets in C, covering the packet format, encoding from node and interface, sending on enabled interfaces, processing on receipt, and timer-driven updates for administrator changes.
Explore the tlv packet format and its prerequisites, clarifying type-length-value structures and related concepts, while previewing the apis for working with trees in future lectures.
Learn to insert tlv entries into a memory buffer with the dlp buffer insert api, manage plb overhead, and obtain the end pointer for subsequent inserts.
Learn to search a tlv in a plb buffer with the dlp api using a start pointer, size, and key, and return the data length and value.
Clarify the simplified halo packet format in the ISIS protocol, detailing the internet header, hello packet fields, payload division, and defining PLB types for implementation.
Learn to implement the hello protocol packet API using the tcp/ip stack library, understand pre-requisites, and gain skills by reading documentation and consulting senior engineers.
Cook hello protocol packets from scratch in C by computing payload size and allocating memory. Populate ethernet and ip headers, and fill fields with interface data and mac addresses.
Write a function to construct the halo packet from scratch, then transmit halo packets periodically on enabled interfaces and stop when the protocol is disabled, using the timeless timer library.
Learn to implement periodic ISIS hello packet transmission using a timer clock, wrapping multiple arguments, and start/stop APIs to send packets out of an interface.
Enable sending hello packets by invoking the hello APIs only on eligible interfaces: protocol enabled, IP configured, and interface up. Stop hellos and free resources when the protocol is disabled.
Enable the protocol on both interfaces, then verify hello packets travel between node R1 and node R2 by checking interface statistics and observing the tcp/ip stack and application layer communications.
Explore packet logging and debugging with the DCP IP Stack Library, using the packet capture utility, enabling selective logging, and registering the ISIS protocol for payload tracing of hello packets.
Register a one-time packet tracing function with the DCP IP Stack Library, which formats and logs incoming packets into log files using the packet print buffer.
Demonstrate packet tracing with the TCP IP Stack Library by logging hello packets from an ethernet interface, enabling trace options, and debugging to verify packet content.
Master inserting traces and printouts for debugging, enabling per-node and per-interface logging in the IP stack library to diagnose race conditions and synchronization issues.
Explore how the ISIS protocol processes incoming packets through its entry point, classifying them as hello or LSP packets and using packet notify data to route processing.
Learn to validate ISIS hello packets with five rejection checks: ensure the interface is enabled and qualified, the destination is broadcast, and IPs share a subnet before updating the interface.
Create and bind an adjacency object to the interface, update from halo packets, and use two boolean flags to track changes and fresh creation during state transitions.
Check status of the project upto this point of development stage as follows .
Download the Src code again in separate dir, say, project_progress
mkdir project_progress
cd project_progress
git clone https://github.com/sachinites/tcpip_stack
git checkout proto-dev2
git reset --hard 40b5289842d5914c7e4ff4173ef4945525ac9a86 ( this is commit hashcode )
use git log to verify , the top commit (at the top of screen) should be shown as below :
commit 40b5289842d5914c7e4ff4173ef4945525ac9a86 (HEAD -> proto-dev2, origin/proto-dev2)
Author: sachinites <sachinites@gmail.com>
Date: Sun Sep 26 12:59:03 2021 -0700
Added hit count to routing table.
Now browse the code at this point (using cscope or otherwise ). Check for show command enhancement we discussed before this lecture video.
To reset the project back to its original state ( latest commit ) use,
git pull
I will share only the commit hash code in a subsequent section of the course when I would want you to check the project dev status up to that point of development in our course. Follow the same procedure as described here. Copy-paste these steps in some text file.
Implement two adjacency timers—the delete timer and the expiry timer—and expose five APIs to start, stop, and refresh them; expiry refreshes on valid hello packets, while delete fires after inactivity.
implement the adjacency delete timer api: start a one-shot five-second timer if not already running, handle the timer callback by nulling references, deregistering, and freeing the adjacency object's resources.
Implement five adjacency expiry timer APIs in C to manage timer callbacks, start/stop/restart timers, and drive the adjacency state through a simple, extendable state machine.
Cover :
Display of Expiry timer remaining
Display of Delete Timer Remaining
Display of Adj Up time
Explore the adjacency state transition diagram for a network interface, detailing transitions from down to init to up via good hello packets, timers, and administrative actions.
Implement the adjacency state transition diagram by switching on old and new states, covering down-to-up, up-to-down, and up-to-up transitions, updating the adjacency state and timers.
Implement adjacency state transitions in a C network protocol, covering down, up, and delete states, halo packet handling, delete timer, and admin actions to free resources on interface disable.
Fix a bug in a C adjacency state machine by adding missing breaks to ensure correct state transitions in a network protocol development context.
What is this Course all about?
This Course presents the Case study in which we implement the Pseudo Interior Gateway Protocol similar to OSPF (Open Shortest Path First) & ISIS (Intermediate System to Intermediate System). Both ISIS and OSPF are IGP protocols that fall under the category of link-state protocols and achieves the same objectives. Don't worry, We shall cover all necessary theories regarding what we shall be going to implement in the project before we hit the first line of code of the project.
This full course is divided into 2 parts - Part A and Part B .
We shall implement the Simplified version of the actual ISIS protocol using our tcp-ip stack library. The goal is to learn the nuances involved in implementing a typical Network protocol on a device from absolute scratch. You will be doing it all your life once you join the industry, but here, this case study aims at giving you firsthand experience regarding what it takes to implement a typical Network protocol on a (simulated) device.
I bet if you are giving an interview in the company for a network developer role, entry-level up to 2-3 yrs of experience, or making a cross-domain switch into Networking Development, seeing the above mention of the project in your resume would give goosebumps to the interviewer. If you could answer cross-questions (I shall be covering in this Course) – you shall be selected without any doubt. Maintain GitHub to present your codes to him if asked.
Project Goals
The AIM of this project is to cycle you through the experience of end-to-end implementation of a typical network protocol. In this case study, we have chosen a routing protocol as an example, but the high-level logistics involved to implement a typical network protocol are more or less the same. For example, a typical network protocol has to:
Configurable via CLIs
Show internal states and results through show CLIs
Respond to generic configuration changes ( such as link shut-down, IP Address on interface change, etc)
Compute results and install the results in Tables (Routing Information Base, MAC Tables, hardware Tables, etc )
Respond to Topological Changes (link failures, device failures, etc )
Time-out stale Data structures if any.
Periodically Generate Or Process Protocol packet
How to add a new feature to the existing working Protocol Codebase. (This is what you shall be doing all your life as a software engineer !!)
Since the project is quite big (I am expecting around 20k LOCs), you would also get the opportunity to learn how to :
Organize the code in header and src files
Modularize the codebase: How to keep the code of different features in different src files
Testing the new feature, and cross-check it doesn’t break existing features
Maintain Code Commits through Version control system ( Github in this case )
Bug Fixing, and exercise various debugging techniques (gdb, Valgrind, etc )
Needless to say, you Can’t exercise the above points unless you do a project of considerable size.
Pre-requisites to do this Course
Needless to say, this project is very challenging, and you need to be reasonably good at Data Structures and Algorithms in C/C++ programming. If you are still struggling with LinkedList/Trees or other common Computer Science basic fundamentals, I would not recommend you spend time on this project – rather work on building your basics first. There is no point in showcasing this project on your resume while at the same time you cannot answer other fundamentals such as questions on Heap Memory, Multithreading, etc, or fail miserably in reversing a linked list.
Also, I shall assume that you have no background in Networking routing protocol (but do possess Networking Basics such as L3 routing, etc ) therefore I shall begin from absolute scratch, covering all necessary theories before we start coding. Along the journey in the implementation, we shall pick up various new concepts related to Networking, Project Planning, feature designing, or Coding Standards at the Industry level.