4  Networking Basics

Key Concepts
  • Computer Network: Two or more devices connected by a communication medium, sharing resources and exchanging data
  • Packet: The fundamental unit of data transmission in modern networks; contains a header (addressing, control) and payload (application data)
  • Protocol: A set of agreed rules governing how devices format, transmit, and interpret messages; enables interoperability between devices from different vendors
  • Bandwidth: The maximum rate at which data can be transferred over a network link, measured in bits per second
  • Latency: The time delay between sending a packet and receiving it at the destination; composed of propagation, transmission, queuing, and processing delays
  • Throughput: The actual rate of successful data transfer achieved on a link, typically less than the theoretical bandwidth due to overhead and protocol inefficiency
  • Reliability: In networking, the property of delivering data correctly (without errors or loss) and in the right order; provided by TCP at the transport layer

4.1 In 60 Seconds

IoT networking relies on layered protocol stacks: the OSI model (7 layers) provides the conceptual framework, while TCP/IP (4 layers) is the practical implementation. Every device needs an IP address for routing (IPv4 or IPv6), a MAC address for local delivery, and appropriate transport protocols (TCP for reliability, UDP for speed) to communicate across the network.

4.2 Learning Objectives

By the end of this chapter, you will be able to:

  • Explain Network Fundamentals: Summarize core networking concepts and articulate why layered protocol stacks are essential for IoT deployments
  • Differentiate OSI from TCP/IP: Compare the 7-layer OSI model with the 4-layer TCP/IP stack and classify which IoT protocols operate at each layer
  • Analyze Protocol Trade-offs: Evaluate TCP vs UDP and select the appropriate transport protocol based on IoT reliability, latency, and power requirements
  • Apply IP Addressing: Calculate IPv4 and IPv6 address spaces, configure device addressing, and predict when NAT limitations require a migration to IPv6

4.3 Prerequisites

Before diving into this chapter, you should be familiar with:

  • Layered Network Models: Understanding the OSI and TCP/IP models provides the theoretical framework that organizes networking concepts into comprehensible layers, which is essential context for this practical introduction to networking
  • Basic computer science concepts: Familiarity with binary numbers, data representation, and basic programming concepts will help you understand protocol operations and addressing schemes
  • General IoT concepts: Basic understanding of what IoT devices are and how they communicate at a high level will help you appreciate why specific networking approaches are used

Meet the Sensor Squad!

Temperature Terry, Light Lucy, Motion Marley, Pressure Pete, and their best friend Signal Sam are a team of tiny sensors living in a smart house. But they have a problem – how do they send their important messages to the Big Computer in the cloud?

Simple Story:

One day, Temperature Terry measured that the kitchen was getting dangerously hot! “I need to tell someone before the cookies burn!” Terry said. But Terry couldn’t just shout – computers don’t have ears! Instead, Terry wrote a tiny digital letter with his message: “Kitchen is 85°C (185°F) – TOO HOT!”

But wait – how does the letter know where to go? That’s where addresses come in! Just like your house has a street address so the mail carrier knows where to deliver letters, every device has a special number called an IP address. Terry’s address might be “192.168.1.25” – kind of like “25 Sensor Street, Kitchen District!”

Signal Sam helped Terry send the letter through the house’s Wi-Fi network. The letter hopped from Terry to the Wi-Fi router (like a local post office), then zoomed through the internet (like a mail truck on the highway), until it reached the Big Computer in the cloud. The cloud sent back a message to the smart oven: “Turn off!” The cookies were saved!

Fun Facts:

  • Every device in your house has its own special address number, just like houses on a street!
  • A “router” is like a post office that knows where to send all the letters
  • Messages can take different paths to get where they’re going – just like you can walk to school different ways
  • The internet has so many devices that we’re running out of old addresses (IPv4) and need longer new ones (IPv6)!

Try This at Home:

Ask a grown-up to help you find your home Wi-Fi router. Count how many devices are connected to it - your tablet, phones, smart TV, maybe even a smart speaker! Each one has its own special address. You can see them by looking at the “connected devices” list in the router’s app. That’s your very own home network!

How This Chapter Fits Into Communication Networks

The Communication Networks part of the module is organised to move from general networking ideas to technology families and then to IoT-specific protocols:

If you ever feel lost in a later networking chapter, you can return to this page to refresh the big picture before diving back into the details.

Protocol Deep Dives:

Learning Hubs:


4.4 Getting Started (For Beginners)

What is Networking? (Simple Explanation)

Analogy: Networking is like a postal system for digital messages. Just like mail needs an address, a route, and a delivery method, digital data needs IP addresses, routing, and protocols to get from your sensor to the cloud.

In everyday terms:

  • IP Address = Your house address (where to deliver data)
  • Router = Post office (decides which way to send your data)
  • Protocol = The rules for how to package and send your letter
  • Port = Like an apartment number (which app gets the data)

4.4.1 The “Layers” Concept (Why It Matters)

Think of sending a package – each layer has ONE job and doesn’t worry about others:

Five-layer protocol stack diagram showing Application, Transport, Network, Data Link, and Physical layers stacked vertically, each with a distinct color and its primary IoT protocols listed
Figure 4.1: Network Protocol Stack with Five Layers

This variant shows the same protocol layers but visualizes what happens to your data as it travels down and up the stack. Each layer wraps (encapsulates) data with its own header.

Data encapsulation timeline showing a 16-byte sensor payload growing to over 100 bytes as Application, Transport, Network, Data Link, and Physical headers are added at each layer when traveling down the protocol stack
Figure 4.2: Data Encapsulation Timeline - Shows how each layer wraps data with headers as it travels down the protocol stack

Key Insight: Your 16-byte temperature reading becomes a ~100+ byte transmission after all headers are added. This overhead is why IoT protocols like CoAP minimize header sizes!

4.4.2 IP Addresses: Your Device’s Home Address

IPv4 vs IPv6 Addressing:

Aspect IPv4 IPv6
Example 192.168.1.100 2001:0db8:85a3::8a2e:0370:7334
Structure Network.Subnet.Subnet.Device Much longer address space
Parts 4 octets (32 bits) 8 groups of 4 hex digits (128 bits)
Address Space 4.3 billion addresses 340 undecillion addresses
Analogy Country.City.Street.House Planet.Country.City.Street.Apt.Room
IoT Suitability Running out (needs NAT) Enough for every IoT device!
Side-by-side comparison of IPv4 and IPv6 address structures: IPv4 shown as four 8-bit octets (e.g., 192.168.1.100) totaling 32 bits with 4.3 billion addresses, and IPv6 shown as eight groups of 16-bit hexadecimal values totaling 128 bits with 340 undecillion addresses
Figure 4.3: IPv4 vs IPv6 Address Structure Comparison

4.4.3 Common IoT Network Types

Network Type Range Speed Power Example Use
Wi-Fi ~50m Fast (Mbps) High Smart TV, cameras
Bluetooth ~10m Medium Low Wearables, speakers
Zigbee ~100m Slow Very Low Smart lights, sensors
LoRaWAN ~15km Very Slow Ultra Low Agriculture, cities
Ethernet ~100m Very Fast N/A (wired) Industrial, servers

4.4.4 Real-World Example: Smart Thermostat

Your Smart Thermostat Sending Data:

Sequence diagram showing a smart thermostat sending a temperature reading through a home Wi-Fi router and internet gateway to a cloud server, which responds with a control command back to the thermostat
Figure 4.4: Smart Thermostat Data Transmission Sequence

4.4.5 Quick Self-Check

Before continuing, make sure you understand:

  1. What is an IP address? - A unique identifier for a device on a network
  2. Why do we use layers? - Each layer handles one job, making systems modular
  3. Wi-Fi vs LoRaWAN? - Wi-Fi is fast/short range; LoRaWAN is slow/long range
  4. What does a router do? - Forwards data between networks based on IP addresses

Cross-Hub Connections: Networking Resources

Enhance your learning with resources across the module’s learning hubs:

Knowledge Map: Explore networking concepts visualization to see how addressing, protocols, and topologies interconnect

Quizzes: Test your understanding with Networking Fundamentals Quiz Bank covering OSI layers, IP addressing, and protocol selection

Simulations: Try hands-on tools in the Simulation Hub:

  • Network Topology Visualizer - Compare star, mesh, tree topologies interactively
  • Protocol Comparison Tool - Evaluate MQTT vs CoAP vs HTTP overhead
  • Power Budget Calculator - Estimate battery life for different protocols
  • Wireless Range Estimator - Model LoRaWAN and Wi-Fi coverage

Video Learning: Watch IoT Networking video series for visual explanations of packet routing, NAT, and gateway operations

Knowledge Gaps: Identify common misconceptions in Networking Troubleshooting - discover why “more bandwidth always means better performance” is false for IoT

These integrated resources provide multiple learning pathways - visual, hands-on, and self-assessment - to reinforce the networking fundamentals covered in this chapter.


As IoT deployments scale to thousands or millions of devices, the choice between IPv4 and IPv6 becomes critical. This framework helps you evaluate which addressing scheme fits your project.

Criterion IPv4 (with NAT) IPv6 (Native)
Address Space 4.3 billion addresses (exhausted) 340 undecillion (effectively unlimited)
Device Scalability Limited by NAT table size (~64,000 per router) No limit (every device gets unique address)
End-to-End Connectivity Requires NAT traversal (complex) Direct peer-to-peer (simple)
Header Overhead 20 bytes (min) 40 bytes (larger BUT simpler processing)
Security IPsec optional IPsec mandatory (built-in encryption)
Router Processing NAT adds latency (1-5ms software NAT) Stateless routing (faster)
Current Adoption Universal (100% compatibility) 35-40% internet, 80%+ cellular IoT
Mobile IoT Support Requires carrier NAT (CGNAT) issues Native support in LTE-M/NB-IoT
Device Provisioning DHCP complexity, port forwarding config SLAAC auto-configuration
Implementation Complexity High (NAT configuration, port forwarding, UPnP) Low (plug-and-play addressing)

Decision Tree:

Q1: How many devices will you deploy?

  • < 50 devices → IPv4 with NAT works fine (small address pool sufficient)
  • 50-1,000 devices → IPv4 with NAT feasible but consider IPv6 for future-proofing
  • > 1,000 devices → IPv6 strongly recommended (NAT breaks at scale)

Q2: Do devices need to be directly addressable from the internet?

  • YES (peer-to-peer, remote access without cloud intermediary) → IPv6 eliminates NAT traversal complexity
  • NO (cloud-brokered communication only) → IPv4 with NAT acceptable

Q3: Are you using cellular IoT connectivity (NB-IoT, LTE-M)?

  • YES → IPv6 required or preferred by most carriers (T-Mobile, Verizon require IPv6 for IoT)
  • NO (Wi-Fi, Ethernet, LoRaWAN) → Either protocol works

Q4: Do you need built-in IPsec encryption?

  • YES (medical devices, financial IoT, security-critical) → IPv6 mandates IPsec support
  • NO (can use application-layer TLS) → Either protocol works

Real-World Examples:

Example 1: Smart Home (30 devices, Wi-Fi, behind single router)

  • Deployment: 30 smart lights, 10 sensors, 5 cameras
  • Network: Single home router with NAT
  • Choice: IPv4 with NAT
  • Why: Small device count fits in NAT table, existing IPv4 infrastructure works, no need for external direct access (cloud-based control via MQTT)
  • Configuration: Router DHCP assigns 192.168.1.100-192.168.1.129 to devices, NAT translates to single public IP

Example 2: Smart Agriculture (10,000 soil sensors, cellular NB-IoT)

  • Deployment: 10,000 sensors across 5,000-acre farm
  • Network: Cellular NB-IoT with carrier network
  • Choice: IPv6 native
  • Why: Carrier requires IPv6 for NB-IoT, 10,000 devices impossible with IPv4 NAT from single IP, each sensor needs unique routable address for firmware updates and commands
  • Configuration: Carrier assigns /64 subnet (18 quintillion addresses available) to farm account, sensors auto-configure using SLAAC

Example 3: Industrial IoT (500 machines, factory Ethernet, isolated network)

  • Deployment: 500 CNC machines, robotic arms, sensors
  • Network: Private 10.0.0.0/16 network (65,536 addresses available)
  • Choice: IPv4 private addressing (no NAT needed)
  • Why: Network is isolated from internet, private IPv4 space provides 65k addresses (plenty for 500 devices), no internet connectivity required, legacy equipment only supports IPv4
  • Configuration: Static IP assignment for machines, DHCP for sensors, no NAT gateway

Example 4: Smart City (1,000,000 streetlights, parking sensors, cameras)

  • Deployment: 1 million devices across metropolitan area
  • Network: Mix of fiber, cellular, LoRaWAN
  • Choice: IPv6 for all endpoints
  • Why: Impossible to NAT 1 million devices behind limited public IPv4 addresses, devices need firmware updates directly (not through cloud), peer-to-peer communication between traffic lights and cameras for incident response
  • Configuration: City gets /32 IPv6 allocation from ISP (2^(128-32) = 2^96 ≈ 79 octillion addresses), devices receive /128 individual addresses, stateless routing

IPv4 NAT Limitations at Scale:

NAT Port Exhaustion Example:

  • Home router with single public IP: 192.0.2.50
  • NAT translation table uses port numbers (0-65535) to multiplex connections
  • Available ports: 65,536 - 1024 (reserved) = 64,512 ports
  • If each IoT device maintains 5 persistent connections (MQTT, HTTP, NTP, etc.)
  • Maximum devices: 64,512 ÷ 5 = 12,902 devices per public IP

For 100,000 device deployment: - IPv4 approach: Need 100,000 ÷ 12,902 = 8 public IPs with complex load balancing - IPv6 approach: Single /64 subnet provides 18 quintillion addresses (1 per device, no multiplexing)

Transition Strategies (Dual-Stack):

For mixed deployments, run both protocols:

Configuration Example (ESP32):

// Support both IPv4 and IPv6
WiFi.begin(ssid, password);

// Wait for both addresses
while (!WiFi.isConnected()) {
    delay(500);
}

IPAddress ipv4 = WiFi.localIP();
IPv6Address ipv6 = WiFi.localIPv6();

Serial.print("IPv4: ");
Serial.println(ipv4);
Serial.print("IPv6: ");
Serial.println(ipv6);

Cost Comparison:

IPv4 with NAT (1,000 devices):

  • Public IPv4 addresses: $2-4/month each × 1 = $48/year
  • NAT gateway hardware: $500 one-time
  • Configuration complexity: High (port forwarding, UPnP, STUN for peer-to-peer)
  • Total 5-year cost: $500 + ($48 × 5) = $740

IPv6 Native (1,000 devices):

  • IPv6 addresses: Usually free from ISP (included in service)
  • No gateway hardware needed (stateless routing)
  • Configuration complexity: Low (auto-configuration)
  • Total 5-year cost: $0

Key Insight: IPv6 is not just “more addresses” – it fundamentally simplifies IoT networking at scale by eliminating NAT, enabling peer-to-peer connectivity, and reducing configuration overhead. For deployments >1,000 devices or using cellular IoT, IPv6 is not optional – it’s required.

Common Misconception: “Wi-Fi is Always Best for IoT”

The Myth: Many beginners assume Wi-Fi is the best choice for all IoT devices because it’s fast, widely available, and familiar from smartphones and laptops.

The Reality: Wi-Fi is often the worst choice for battery-powered IoT sensors due to power consumption.

Quantified Impact:

  • Wi-Fi power consumption: 240-360 mA active transmit, 50-100 mA idle (always listening)
  • Bluetooth LE: 15-20 mA active, 0.4-3 mA sleep mode
  • LoRaWAN: 40-120 mA transmit (brief bursts), <1 µA deep sleep

Real-World Example: A temperature sensor sending readings every 5 minutes:

  • With Wi-Fi (constant connection): 2000 mAh battery lasts ~20 days (idle power dominates)
  • With Bluetooth LE (sleep between readings): Same battery lasts ~8 months (95% time in sleep)
  • With LoRaWAN (deep sleep between transmits): Same battery lasts ~3-5 years (99.9% time asleep)

Why This Matters: Wi-Fi’s “always listening” architecture drains batteries fast. For 10,000 agricultural sensors across 100 acres, choosing Wi-Fi over LoRaWAN means replacing batteries 15x more often – costing $150,000/year extra in maintenance.

When Wi-Fi Makes Sense: Mains-powered devices (cameras, smart speakers), high-bandwidth needs (video), existing Wi-Fi infrastructure, low-latency requirements (<50ms).

The Right Approach: Match protocol to power budget, not familiarity. Battery-powered = Bluetooth LE, Zigbee, or LoRaWAN. Mains-powered = Wi-Fi or Ethernet.

Try It: IoT Protocol Battery Life Calculator

Adjust the parameters below to see how protocol choice and duty cycle affect battery life for a sensor sending periodic readings.


4.5 Why Networking Matters for IoT

Time: ~8 min | Foundational | P07.C14.U01

IoT devices are only as useful as their ability to share data. A temperature sensor that cannot transmit readings, a motion detector that cannot trigger alerts, or an actuator that cannot receive commands – all become expensive paperweights. Networking is the connective tissue that turns individual sensors into a coordinated system. Two technical choices drive most IoT networking decisions: IP addressing (how devices are identified and routed to) and protocol selection (how data is packaged and delivered). The calculations below show just how much scale matters for the first choice.

IPv6 Address Space Calculation

The IPv4 vs IPv6 table above showed that IPv6 has “340 undecillion” addresses. Here is the exact derivation, so you can see why that number is so consequential for IoT at scale:

\[\text{IPv4 addresses} = 2^{32} = 4{,}294{,}967{,}296 \approx 4.3 \text{ billion}\]

\[\text{IPv6 addresses} = 2^{128} = 340{,}282{,}366{,}920{,}938{,}463{,}463{,}374{,}607{,}431{,}768{,}211{,}456\]

The ratio tells the story:

\[\frac{\text{IPv6}}{\text{IPv4}} = \frac{2^{128}}{2^{32}} = 2^{96} = 7.9 \times 10^{28}\]

That’s 79 octillion times larger. To visualize: if every grain of sand on Earth (≈7.5×10^18) had an IPv4 internet, IPv6 could give each grain 10 billion such internets.

For IoT scale: with 75 billion projected devices by 2030, IPv6 allocates:

\[\frac{2^{128}}{75 \times 10^9} \approx 4.5 \times 10^{27} \text{ addresses per device}\]

This explains why IPv6 enables every IoT sensor to have a globally routable address without NAT, fundamentally changing IoT network architecture from the NAT-dependent IPv4 model.

Try It: NAT Port Capacity vs. IPv6 Scale

Enter your deployment size to see whether IPv4 NAT can handle it – and how many IPv6 addresses remain per device.

4.6 Review Activities

Match: IoT Network Technologies to Their Characteristics

Order: Steps in IoT Sensor Data Transmission


4.7 Videos

Networking Fundamentals (Part 1)
Networking Fundamentals (Part 1)
From Lesson 4 - core concepts used throughout IoT networking.
Networking Fundamentals (Part 2)
Networking Fundamentals (Part 2)
From Lesson 4 - building blocks for layered models and protocols.

Common Pitfalls

A 100 Mbps Ethernet link may only deliver 60–70 Mbps throughput due to protocol overhead, retransmissions, and half-duplex contention. Fix: always use measured throughput rather than link speed for capacity planning.

Latency has four components: propagation (distance/speed of light), transmission (packet size/bandwidth), queuing (buffer wait time), and processing (router/switch forwarding delay). Fix: identify which component dominates latency in your deployment and optimise accordingly.

Wireless IoT networks experience packet loss from RF interference, multipath fading, and hidden nodes — not congestion. Applying TCP-style congestion control to wireless packet loss causes unnecessary throughput reduction. Fix: diagnose the cause of packet loss before applying a remedy.

4.8 What’s Next

Now that you have explained core networking concepts, differentiated OSI from TCP/IP, and applied IPv4/IPv6 addressing, the chapters below build directly on these foundations:

Topic Chapter Description
Protocols and MAC Networking Basics: Protocols and MAC Common IoT protocols classified by OSI layer and Medium Access Control strategies for shared wireless channels
Hands-On Configuration Networking Basics: Hands-On Configuration Practical network configuration, subnetting, security hardening, and systematic troubleshooting workflows
Labs and Practice Networking Basics: Labs and Practice Interactive Python implementations, Wokwi ESP32 networking simulations, and cumulative knowledge checks
Layered Models Deep Dive Layered Models Fundamentals Detailed walkthrough of every OSI layer with IoT-specific protocol examples at each level
IoT Protocol Landscape IoT Protocols: Fundamentals Cross-layer view of MQTT, CoAP, AMQP, and HTTP/2 showing how application protocols map to the transport stack
Wireless Technology Families Mobile Wireless Technologies Basics Comparative analysis of Wi-Fi, Bluetooth, Zigbee, LoRaWAN, and cellular IoT with protocol selection criteria