Skip to main content

TCP/IP Fundamentals

Volume 2 — Networking Foundations

Most of the debugging you'll ever do — a CORS error, an API timeout, a database connection that works locally but not from Azure, a certificate warning — traces back to something in this chapter. This is the foundation the rest of Volume 2 (DNS, SSL/TLS, VPNs, load balancers) builds on.

1. The OSI Model vs. the TCP/IP Model

The OSI model is the theoretical, 7-layer way of describing network communication. TCP/IP (what the internet actually runs on) collapses it into 4 practical layers. You'll hear both — here's how they map:

OSI LayerOSI NameTCP/IP LayerWhat lives here
7ApplicationApplicationHTTP, HTTPS, DNS, SMTP — the protocols your app actually speaks
6PresentationApplicationTLS/encryption, data formatting
5SessionApplicationSession management
4TransportTransportTCP, UDP — ports, reliability, ordering
3NetworkInternetIP addresses, routing
2Data LinkNetwork AccessMAC addresses, switches
1PhysicalNetwork AccessCables, wifi signals, actual bits on the wire

In day-to-day debugging you'll mostly live at the Application and Transport layers: is the DNS name resolving, is the port open, did the TLS handshake succeed, did the HTTP request get a response. The lower layers matter mostly when connectivity is broken at a more fundamental level (no network at all, VPN down).

2. IP Addresses

An IP address identifies a device on a network — like a mailing address for data.

IPv4 — four numbers 0–255, separated by dots:

192.168.1.42

IPv6 — designed to solve IPv4's limited address space (roughly 4.3 billion addresses, which the internet has now exhausted), written as eight groups of hex digits:

2001:0db8:85a3:0000:0000:8a2e:0370:7334

You'll work with IPv4 far more often day to day, but Azure resources increasingly support IPv6 alongside it, and it's worth being able to recognize one when you see it in logs or configuration.

Public vs. private addresses

Certain IPv4 ranges are reserved for private networks and are never routable on the public internet:

RangeCommon use
10.0.0.0 – 10.255.255.255Large private networks — this is the range Azure VNets typically use
172.16.0.0 – 172.31.255.255Private networks, often Docker's default range
192.168.0.0 – 192.168.255.255Home/small office networks
127.0.0.0 – 127.255.255.255Loopback — 127.0.0.1 is always "this machine"

This is why your laptop and an Azure VM can both have the address 10.0.0.4 without conflict — they're private addresses meaningful only inside their own network. Public-facing services (like api.roundtrips.app) resolve to a public IP address that's globally unique.

3. Subnetting and CIDR Notation

CIDR (Classless Inter-Domain Routing) notation describes both an IP address and how many bits of it are "fixed" (the network portion) vs. flexible (the host portion), written as address/prefix-length.

10.0.0.0/24

The /24 means the first 24 bits are the fixed network portion, leaving 8 bits (2^8 = 256 addresses, 254 usable) for individual hosts on that subnet.

CIDRTotal addressesUsable hostsCommon use
/3211A single specific host
/2986A tiny subnet, e.g. a small VNet subnet
/24256254A typical subnet size
/1665,53665,534A typical whole VNet address space
/816,777,21616,777,214An entire large private range

("Usable" is 2 less than total because the first address identifies the network itself and the last is the broadcast address — neither is assignable to a host.)

Why this matters practically: when you set up an Azure VNet with address space 10.0.0.0/16 and carve out a subnet 10.0.1.0/24 for App Services and another 10.0.2.0/24 for a database, CIDR notation is how you're describing "this subnet gets these 254 addresses, that one gets a different 254" without them overlapping.

4. Ports

A port identifies which service on a given IP address a connection is meant for — the IP gets you to the right machine, the port gets you to the right application on it.

PortProtocol/Service
22SSH
53DNS
80HTTP
443HTTPS
1433SQL Server / Azure SQL
5432PostgreSQL
3306MySQL
6379Redis
5672RabbitMQ (AMQP)

Ports 0–1023 are "well-known" ports, conventionally reserved for standard services (the ones above). Ports above 1024 are free for applications to use as needed — including the temporary, randomly-assigned "ephemeral" ports your machine uses as the source port for outbound connections (you connect from some ephemeral port on your laptop to port 443 on a server).

curl -I https://api.roundtrips.app:443 # explicit port, though :443 is the default for https:// and can be omitted

5. TCP vs. UDP

Both are transport-layer protocols, but with opposite trade-offs:

TCPUDP
ConnectionConnection-oriented (handshake first)Connectionless (just send)
ReliabilityGuaranteed delivery, retransmits lost packetsNo guarantee — lost packets stay lost
OrderingGuaranteed in-order deliveryNo ordering guarantee
SpeedSlower (overhead from guarantees)Faster (no overhead)
Typical useHTTP/HTTPS, database connections, SSH — anything where correctness matters more than raw speedDNS queries, video/voice streaming, gaming — anything where a dropped packet is better than a delayed one

The TCP three-way handshake — what happens before any TCP data flows at all:

This handshake happens for every new TCP connection — including every fresh HTTPS request that isn't reusing an existing connection — before a single byte of your actual request is sent. It's also why a firewall silently dropping SYN packets (rather than actively rejecting them) makes a connection hang rather than fail immediately — the client just keeps waiting for a SYN-ACK that will never come.

6. NAT (Network Address Translation)

NAT is what lets many devices on a private network share one public IP address. Your home router does this constantly: every device on your home wifi has a private 192.168.x.x address, but to the outside internet, all of their traffic appears to come from your one public IP.

Azure VNets work the same way by default — resources with only private IPs reach the internet outbound through NAT (Azure's default outbound access, or an explicit NAT Gateway resource for more control), without needing individually assigned public IPs.

7. Routing

A routing table is how a device decides which direction to send a packet based on its destination address. Every device — your laptop, a router, an Azure VM — has one.

# View your machine's routing table
netstat -rn # macOS
ip route # Linux

The default gateway is the "if nothing more specific matches, send it here" entry — typically your router (at home) or the VNet's default route (in Azure), which then forwards it further toward its destination.

8. How This Maps to Azure Networking

Concept in this chapterAzure equivalent
A private network / subnetVirtual Network (VNet) and its subnets
Which traffic is allowed in/outNetwork Security Group (NSG) rules
NAT for outbound internet accessDefault outbound access, or an explicit NAT Gateway
Public IP for a servicePublic IP resource, or the default public endpoint on App Service
Routing between subnets/VNetsRoute tables, VNet peering

A concrete example: Azure SQL restricted to only accept connections from your App Service's outbound IPs is a firewall rule operating at the IP-address level described in Section 2 — this is why an App Service's outbound IP changing (which can happen on scale operations) can suddenly break a database connection that was working fine the day before, with no code changes involved.

9. Practical Developer Workflows

Check what public IP your machine is currently using (useful when configuring a firewall allow-rule):

curl -4 ifconfig.me

Confirm a specific port is actually reachable (not just that the host resolves):

nc -zv api.roundtrips.app 443

Trace the network path to a host — useful when something is slow or unreachable and you need to know where along the route it's failing:

traceroute api.roundtrips.app # macOS/Linux

10. Troubleshooting Playbook

SymptomLikely layer/causeWhat to check
Connection hangs, never times out cleanlyFirewall silently dropping SYN packetsCompare against a host you know is reachable; check NSG rules if it's an Azure resource
Connection actively refused, fails immediatelyNothing listening on that port, or an active reject ruleConfirm the service is actually running and bound to the expected port
Works from your laptop, fails from Azure App ServiceDifferent outbound IP, different NSG/firewall contextCheck the target's firewall for App Service's specific outbound IPs, not just your local IP
Intermittent connectivity, sometimes worksOutbound IP changed after a scale event, or NAT port exhaustion under loadCheck App Service's current outbound IPs; consider a NAT Gateway for high-volume outbound scenarios
"No route to host"Routing table has no path to the destinationip route / netstat -rn; confirm VNet peering or gateway configuration if it's a private Azure resource
Works over HTTP, fails over HTTPS onlyAlmost always a TLS/certificate issue, not a TCP/IP oneSee the SSL/TLS Explained chapter — the TCP connection itself is likely fine
Can reach an IP directly but not by hostnameDNS issue, not a TCP/IP issueSee the DNS Deep Dive chapter

11. Quick Reference

CategoryItemDetail
Private ranges10.0.0.0/8Large private networks, common in Azure VNets
Private ranges192.168.0.0/16Home/office networks
Loopback127.0.0.1Always means "this machine"
CIDR/24256 addresses, 254 usable — a typical subnet
CIDR/1665,536 addresses — a typical whole VNet
Ports443HTTPS
Ports1433Azure SQL / SQL Server
ProtocolTCPReliable, ordered — HTTP(S), databases, SSH
ProtocolUDPFast, no guarantees — DNS, streaming
HandshakeSYN → SYN-ACK → ACKRequired before any TCP data flows
Commandnc -zv host portTest whether a specific port is reachable
Commandtraceroute hostShow the network path to a destination
Commandcurl -4 ifconfig.meShow your current public IP

Part of the Traxs Engineering Handbook — Volume 2: Networking Foundations. Companion chapters in this volume: DNS Deep Dive, SSL/TLS Explained, VPN Fundamentals, Network Troubleshooting, Load Balancers & Reverse Proxies.