
Define goals and prerequisites for the TCP/IP stack course, and build a graph library to model a topology with routing devices and links, enabling packet simulations for Part B.
The pre-requisite of this Course is that you have a thorough knowledge of Layer 2 and Layer 3. For that you can enroll into my Other networking course here : https://www.udemy.com/course/network-programming-from-scratch/?instructorPreviewMode=guest
and complete section no : 3 ,4 and 5.
Explore future project extensions to the tcp/ip stack project, enabling layer two and three routing, ip fragmentation, ip in ip encapsulation tunnels, and other extensible networking functionalities with unlimited scope.
Explore goals to build a practical tcp/ip stack with layer two and layer three functionality. Implement mac learning, address resolution, packet parsing, and traffic forwarding on a single machine.
In testapp.c file, we need to load the correct topology which I used for showing the Demo.
In testapp.c , inside main fn replace line :
topo =<some topology name>();
with
topo = build_square_topo();
recompile and rerun.
If it is already there, then no problem.
Build a generic graph by implementing data structures and APIs, then test with a sample app, modeling nodes, interfaces, and links to form a network topology.
Define graph data structures: topology name, node list, interfaces, and links with cost, using GL threads as a linked list variant; cover forward declarations and basic git repository practices.
Construct a generic graph by creating a graph, adding nodes, and inserting bidirectional links with interfaces and costs, assembling a three-node topology R0, R1, R2.
Design and implement graph apis in c to create graphs, add nodes, and insert links with interfaces and back pointers, then dump the graph to verify topology.
Learn to use a Makefile to automate building your C project with gcc, manage source and object files, and extend the build as new files are added.
Implement APIs to configure loopback and interface ip with mask, declare in net.h, implement in net.c, auto generate unique mac addresses, and dump the network graph.
Enhance a basic graph into a network topology by assigning IP addresses to interfaces and loopback addresses to nodes, and implement a dump function to output the network graph.
This Course is dependent on this External LIBCLI Library. I have added all Videos of this separate course in Appendix E.
integrate the lip cli library into the tcp ip stack project by downloading, placing, compiling with make, and updating the makefile to link the library and build the command parser.
Implement the first command line interface for the tcp/ip stack by wiring show topology to dump the network graph, integrating the libcloud library, and registering the topology handler.
Discuss the design change to enable inter-node communication overlaying the network topology by opening multiple udp sockets on ports 40001 and 40002 and handling 127.0.0.1 loopback.
Implement a packet receiver thread to listen on all UDP sockets of topology nodes using the pthread library, select, and fd sets, and process data with the packet receive API.
Part b implements layer two and layer three routing, including arp state machine, mac based forwarding, static L3 routes, a ping or trace route utility, and vlan support later.
Implement the address resolution protocol (arp) as the first milestone and verify its operation, then test layer 2 switching with arp broadcasts on a simple three-node topology.
Explore how routing device interfaces switch between l3 and l2 modes, configure ip addresses, and apply vlan tagging with trunk and access modes, including arp behavior and mac matching.
Define the ethernet header structure in C for the data link layer, including destination and source mac, type, payload, crc, with hash pragma pack to avoid padding.
Understand how a routing device on an interface decides to accept or reject a packet using l3 mode, mac checks, broadcast rules, and l2 frame receive qualify on interface api.
Explain how to right-shift packet buffers for TCP/IP stack processing, implement the packet buffer shift API in net.c/net.h, and connect layer two to the stack with testing.
Handle packet buffers and headers with extreme care to avoid memory corruption, a hard debugging problem. Use gdb and inserted print statements to verify behavior before coding.
Explain how Ethernet and ARP headers are populated for a broadcast ARP request and an ARP reply, including MAC/IP addresses, opcode, and next-hop IP 10.1.1.2.
Define the arp table as a linked list of arp entries that map ip addresses to mac addresses and the outgoing interface, with a three-node topology example.
Implement arp table CRUD APIs using IP as the key, including lookup, add, delete, update, and dump, while managing a linked-list of arp entries and data copy from messages.
Use the arp cli to specify a node name and ip address, triggering an arp broadcast request and updating the arp table with the resolved mac mapping.
Implement an arp broadcast request by allocating memory for the ethernet header and arp header, filling mac/ip fields, and dispatching the broadcast via the resolved interface.
Process the arp reply api when a node receives a broadcast reply, print the event, and update the arp table with the reply on the interface, completing the arp cycle.
Understand how a received frame enters the TCP/IP stack via layer 2 frame receive, including the interface qualification decision and how processing depends on layer 3 or layer 2 handling.
Implement frame ingress into the tcp/ip stack by validating l2 criteria on the interface, inspecting the ethernet header to process arp requests and replies, or ip packets on l3 interfaces.
Explain how arp resolves addresses when a layer 3 router forwards to next hop or delivers to a subnet host, and prepare to implement layer 2 switching with mac-based forwarding.
Explore layer two switching and MAC-based forwarding in a four-host topology, where an L2 switch with no IP addresses learns MAC addresses and forwards frames using the Ethernet header.
Refresh your L2 switching knowledge, including MAC learning and forwarding, and LANs and VLANs concepts, before implementing L2 and L3 routing in C.
Explore the difference between switches and routers, and how IP addresses, access and trunk modes, and dual function bridges define L2 and L3 behavior on interfaces.
Define an access and trunk enum and extend interface properties to store L2 mode; implement a robust layer two API to switch to L2 or L3, and update topology display.
Build a four-host l2 switch topology by implementing topology.c API, configure loopback and host ip addresses, set the switch interface to access mode, and start the packet receiver thread.
Explore how an L2 switch learns source MAC addresses and forwards frames using destination MACs, flooding when entries are missing, and handling broadcast frames in a four-host topology.
Explore how the layer2 frame receive API is the entry point for frames into a routing device, deciding tcp/ip processing or l2 switch mac learning and forwarding by interface type.
Explains VLAN tagging in L2 switches, introduces 802.1q VLAN header, and tagged vs untagged Ethernet frames, TPID 0x8100, four-byte VLAN header, and 12-bit VLAN ID up to 4095.
Define new data structures for vlan tagging: a vlan 802.1 header and a vlan ethernet header, embedded in the tagged ethernet header, to support vlan in layer two.
Explain how a layer 2 switch detects tagged versus untagged ethernet frames. Show how reading bytes 13–14 and the 8100 value decides tagging and enables the is_packet_vlan_tagged API.
Develop C APIs to tag and untag ethernet frames with 8021 Vlan headers for L2 switching, handling right-shifted frames, adjusting packet sizes, and updating existing Vlan headers when already tagged.
Explore how to implement tagging and untagging of ethernet frames with a VLAN ID using the 802.1 VLAN header, including packet buffer shifts, temporary memory, and FCS updates.
Build and verify a two l2 switch vlan topology with six hosts, illustrating vlan ten and vlan 11 through access and trunk interfaces and vlan membership.
Identify how the frame ingress path tags frames with a VLAN ID when required and passes tagged or untagged frames to the L2 switching MAC learning and forwarding process.
Implement the L2 switch send packet out API to evaluate six egress cases, deciding whether to forward frames based on interface mode, VLAN tagging, and 802.1q header handling.
implement the l2 switch frame egress logic by validating interface modes, extracting 802.1q vlan headers, handling tagged and untagged frames, and delivering untagged frames on trunk or access paths.
Upgrade the l2 switch forward frame API to support vlan based forwarding using flat packet out and send packet out, handling broadcast or mac table lookups.
Student Level: Intermediate to Advanced to Working Professionals, Beginners in Coding pls excuse this course.
Talk to your Prof: Use this Project as your Final Year Under-Grad Project
Note: If you are buying this course, pls do not buy my other course on - "Integrate CLI interface to you C/C+++ Project". It's all videos that are already included in this course.
This is a 100% Coding based Course in C in which we will develop a TCP/IP Stack from scratch having Data Link Layer, Network Layer and Application Layer in Operation. This is one big project split up into 6 mini-projects. The development of the sister course (Part-B) is in progress.
This Course will set you ready for a core network developer's role in the industry. If you are thorough with basics of L2 Routing including ARP, L3 routing, then probably you already have the required knowledge for this project-based course. If not, you should enroll in to my course - "Networking Concepts and Programming from Scratch" and at-least do section number : 3 to 5. For VLANs implementation section 6,7, and 8 is required. We shall be implementing this theory in C now. If you have some other favorite language, feel free to do this course in that, I don't mind, but I shall be explaining logic and showing the demos in C only.
In this course, We shall be implementing a TCP/IP Stack demo through 6 Networking Projects. All Below Projects should be done in the same sequence as listed.
Project 1 : Build a MultiNode Topology Emulation of Routers and Switches
Project 2 : Implement DataLink Layer (L2 routing), including ARP
Project 3 : Implement L2 Switching (Mac-based Learning and Forwarding)
Project 4 : Implement Vlan Based Mac learning and Forwarding
Project 5 : Implement Network Layer (L3 routing)
Project 6 : Case Study : Implement IP-Tunnelling (Optional)
In these mini Projects, we shall be implementing the packet Journey Upwards and Downwards through layers of TCP/IP Stack (= OSI Model). We shall be implementing the TCP/IP Stack !! There is minimal Socket Programming in this course. Not every Networking project has to be socket programming based.
Along the way, we shall be discussing and implementing the solution to new challenges we encounter while solving the problem. Based on how this course is accepted by students, I would add more projects to this course based on the student's feedback.
After Doing These Projects, you shall be able to :
1. Tell why you need Data link layer and Network Layer
2. How to design a new Application protocol on a TCP/IP stack (just like ICMP, HTTP, etc all work on TCP/IP Stack)
3. Get your hands dirty with industry-level network programming.
4. Learn cooking up, parsing and reading the packet buffers
5. Understand End-To-End Architecture and Design of Network Application and TCP/IP Stack
6. Conquer Interviews for the role of Network Developer Engineer
7. Decorate your GitHub, and add a strong project to your HAT, Expected LOCs of this course shall exceed 10k !
This project will fill up the gap between theoretical knowledge and the Implementation version of it. How does it sound that you have written code by your own hands to resolve ARP, packet forwarding, etc. Decorate your resume and GitHub with this project.
This course is divided into Two Parts :
Part A - In this part of the course, we shall be building up the Network topology Infrastructure comprising of routers, switches, and links connecting them. Nodes can also exchange packets with their neighbors. Basically, we want to simulate a fully programmable and configurable network topology in this part of the course. This is Project 1.
Part B - The Configurable Network Topology build in Part A of the course shall be used to implement the Remaining five Projects [2-6] as listed above.
We shall be setting up all the required infrastructure to mimic the network topology - and that itself is a mini project altogether. We shall be creating nodes, links connecting nodes, configuring network parameters on nodes, sending and receiving traffic streams - All in one project. This is Megaproject, expected LOC may go to tens of thousands if we keep on adding TCP/IP stack features onto it. The sky is the limit.
The best thing about this project is - You will learn many other things along the journey, including setting up Timers, Network Topology Construction, Glthreads - A Glue way of Linked lists, Building Project using Makefile and I am not even talking about learning Software Designing skills. Additional Material has been added in the Appendix Section of the course. We shall be modularizing the project in separate folders, each folder contains code implementing a particular OSI Layer functionality, and Yes, We shall be doing it all from scratch.
Warning :
1. Absolute beginners, struggling with basic data structures and pointers, pls excuse this course. You are not prepared for this project. Pls, invest your time into learning basics first.
2. Machine Used: Ubuntu 19.04, GCC compiler. So my codes may not compile on your machine if you are using some other compiler or machine.
Table Of Contents :
********
PART A
********
[ PROJECT 1]
Section 1. KYC (Know your Course)
Section 2. Developing a Generic Graph Topology
Graph Data structures
Graph related APIs
Creating our first static graph
Section 3. Construction of a Network Graph Topology
Adding Network topology details to the graph
APIs to configure Network Topology
Get ready without first Hello World Network Topology
Section 4. Command-Line Integration
Integrate CLI Interface to the project
Write Custom Commands to Display Network Topology detail
Section 5. Communication Setup
Sending a packet to Nbr node on the outgoing interface
Listening and Monitoring Multiple Sockets
Receiving a packet on an interface
********
PART B
********
Section 6. Agenda of Part B
[ PROJECT 2]
Section 7. Getting Started with TCP/IP Stack Development
Interface Modes
Ethernet Header Format
Assignment on Ethernet Header Manipulation
Packet Processing Criteria
Packet Buffer Management
Section 8. Implement Layer 2 (DataLink Layer) - ARP
Get started with ARP Implementation
ARP Message Format and Example
Creating ARP Tables
CRUD APIs on ARP Tables
CLIs to work with ARP
ARP Cycle and ARP APIs
Preparing and Sending ARP Broadcast request msg
Processing ARP Broadcast Request msg
Sending ARP reply Msg
API to Start Ingress Journey of the Frame
Processing ARP reply msg and create an ARP entry in ARP table
ARP in Action
[ PROJECT 3]
Section 9. Implement Layer 2 (DataLink Layer) - L2 Switching
APIs to configure node as L2 switches
Setting up the new Topology with L2 switches and host machines
Implementing MAC learning and Forwarding algorithms
MAC Table Management of L2 switches
Testing L2 switching behavior using ARP
[ PROJECT 4]
Section 10. Layer 2 - Implementing Vlan Based Forwarding
Goals and Pre-requisites
802.1Q Vlan hdr format
Vlan Tagged Ethernet Header Data Structures
API to determine Tagged Vs Untagged frames
Tagged <--> Untagged Frame Conversion
Vlan Based MAC Forwarding - Further Roadmap
Frame Ingress Condition Table
Frame Ingress Completion
Frame Egress Condition Table
Egress Frame Completion
Test Vlan Based Forwarding
[ PROJECT 5]
Section 11. Setting Up Layer 3 Routing Infrastructure (Network Layer)
Goals and Pre-requisites
L3 Routing Table Setup
CRUD APIs for Routing Table Mgmt
L3 Route Installation
Defining IP HDr format
Adding Ping CLI
Network and Application Layer Interaction
L3 Routing Concepts Revisited
Forwarding Case
Direct Host Delivery Case
Local Delivery Case
Self-Ping Case
L3 Routing Flowcharts
Section 12. Layer 3 Routing Flowcharts Implementation
Payload Data Transfer from L2 to L3
Layer 3 Flowchart Implementation - Step by Step
Layer 3 Operations Flowchart Implementation
Layer 2 Operations Flowchart Implementation
Testing Beta Version of our Project
Section 13. On-Demand ARP Resolution
Problem Statement
Solution Strategy
Data Structure Enhancements
ARP Sane Entry Creation
ARP Pending List Processing
Final Demo of our Complete Project
[Project 6]
Section 14. Implement IP-IN-IP Encapsulation (Tunneling)
Implement IP-IN-IP Encapsulation (Tunneling)
Future Extension of the Project. Students are supposed to take this forward on their own.
Section 15. Routing between two Vlans (Inter Vlan Routing)