A comprehensive guide to networking concepts and network programming in Python — from the OSI model and IP addressing to socket programming, security, and automation.
Networks are the backbone of modern computing. Whether you’re building web applications, managing infrastructure, or developing IoT devices, understanding how networks operate — and how to program them — is an essential skill.
This book takes you on a journey from the foundational concepts of networking (the OSI model, IP addressing, IPv6, routing) through practical network architecture and security (firewalls, DMZ, TLS) and into hands-on network programming with Python. You’ll learn to build TCP and UDP servers, work with asynchronous networking, craft and analyze packets, and automate network operations.
Each chapter combines clear theoretical explanations with practical code examples you can run immediately. By the end, you’ll have a deep understanding of how networks function at every layer and the programming skills to build, secure, and automate networked systems.
socketserverasyncio streams and event loopsThe book is organized into four parts that progressively build your knowledge:
Part 1 — Networking Fundamentals (Chapters 0–3) starts with the motivation for learning network programming, then covers the OSI and TCP/IP reference models, IP addressing (both v4 and v6), and practical Linux network configuration.
Part 2 — Network Architecture & Security (Chapters 4–6) dives into switching, routing, and VLANs, then explores firewalls, NAT, and DMZ design. It wraps up with TLS encryption and certificate management.
Part 3 — Network Programming in Python (Chapters 7–10) is the hands-on core of the book. You’ll master socket programming, build TCP and UDP servers, leverage asynchronous I/O for high-performance networking, and work with HTTP APIs and WebSockets.
Part 4 — Advanced Topics (Chapters 11–13) covers packet-level analysis with Scapy, network automation via SSH and SNMP, and concludes with troubleshooting techniques and best practices for production systems.
All code examples in this book are written in Python 3.10+ and are available in the code/ directory. Inline code snippets are kept short (under 20 lines) for readability; full working examples are provided as standalone scripts you can run and modify.
The book assumes basic Python proficiency and a Linux or macOS environment for running examples. Most concepts apply cross-platform, but command-line examples use Linux tools and syntax.