Sockets โ€“ Fundamentals of TCP/IP Networks

 

Chapter 58: Sockets โ€“ Fundamentals of TCP/IP Networks
Linux Programming Interface Series | EmbeddedPathashala
๐Ÿ“„ 3 Tutorial Files
๐Ÿ’ฌ 25+ Interview Q&A
๐Ÿ’ป 10+ Code Examples

This chapter covers the network fundamentals you need before writing socket programs. You will learn what an internet is, how the TCP/IP protocol stack is organized, what encapsulation means, and what the data-link layer does โ€” including the critical concept of MTU that affects every socket application you write.

Topics Covered
internet vs Internet subnet / router multihomed host TCP/IP history protocol layers protocol stack encapsulation transparency SOCK_STREAM SOCK_DGRAM SOCK_RAW ARP / ICMP / IGMP data-link layer frame MTU MSS Path MTU Discovery netstat -i RFC

Part 1 โ€” Internets and TCP/IP Introduction

Learn what an internet is, how TCP/IP came about, the difference between a router and a multihomed host, and what RFC documents are. Includes C code to list network interfaces and detect multihomed machines.

internet vs Internet subnets router multihomed host ARPANET / DARPA 4.2BSD RFC getifaddrs()

Part 2 โ€” Protocol Layers, Transparency and Encapsulation

Understand how the four TCP/IP layers work together, what transparency means for socket programming, and how data is encapsulated and de-encapsulated as it travels down and up the stack. Includes SOCK_STREAM, SOCK_DGRAM, SOCK_RAW examples and a raw socket IP header reader.

protocol layers protocol stack TCP / UDP / IP ARP / ICMP / IGMP transparency encapsulation segment / datagram / frame socket() call SOCK_RAW

Part 3 โ€” The Data-Link Layer and MTU

Deep dive into the data-link layer โ€” what it does, what a frame looks like, and why MTU is critical for socket programming. Learn how to read MTU with ioctl, how TCP MSS is derived from MTU, and how Path MTU Discovery works.

data-link layer frame structure MTU = 1500 bytes IP fragmentation TCP MSS = 1460 SIOCGIFMTU ioctl IP_MTU_DISCOVER netstat -i

Quick Reference: Chapter 58 in One Table
Layer Protocol(s) Data Unit Socket API
Application HTTP, SSH, your program message / data read() / write()
Transport TCP, UDP segment SOCK_STREAM / SOCK_DGRAM
Network IP, ICMP, ARP, IGMP datagram SOCK_RAW
Data-link Ethernet, Wi-Fi driver frame (MTU 1500) Not directly accessible

EmbeddedPathashala
Free tutorials for Linux system programming and Bluetooth/BLE

Visit Website

Leave a Reply

Your email address will not be published. Required fields are marked *