Before you can write socket programs that talk over a network, you need to understand what a network actually is and how TCP/IP organizes communication. This part lays that foundation — covering what an internet is, how TCP/IP became the dominant protocol suite, what a router does, and what RFC documents are.
The word internet (lowercase i) means an internetwork — a system that connects different computer networks together so that every host on every connected network can communicate with every other host.
Think of it like this: your home has a local network (your Wi-Fi). Your office has its own network. An internet is what bridges those separate networks into one big reachable space.
The individual networks inside an internet are called subnetworks or subnets.
The key goal of an internet is to hide the differences between physical networks. Whether Network A uses Ethernet cables and Network B uses fiber optic links, the internet presents a single, unified addressing format to every host. You do not need to know what the lower-level network looks like; you just use an address.
Internet (uppercase I) refers specifically to the global TCP/IP internet — the one connecting billions of devices worldwide.
TCP/IP did not appear overnight. It grew out of a US government research project.
ARPA became DARPA (adding “Defense”). The protocol suite is formally called the DARPA Internet Protocol Suite, but everyone calls it TCP/IP — named after its two most important protocols: Transmission Control Protocol (TCP) and Internet Protocol (IP).
TCP/IP won the competition against proprietary networking protocols (like Novell’s IPX and IBM’s SNA) and became the universal standard. Today every networked device speaks TCP/IP.
A router is a machine whose job is to connect two or more subnets and move packets between them. It must understand the internet-layer protocol (IP) and also understand the data-link-layer protocol of each subnet it connects.
A router has one network interface per subnet it connects. Each interface has a separate address on that subnet.
(Router)
The general term multihomed host means any host with more than one network interface — not necessarily a router. A server connected to both an internal LAN and an external network is multihomed. A router is just a multihomed host that also forwards packets from one subnet to another.
| Property | Multihomed Host | Router |
|---|---|---|
| Multiple interfaces | Yes | Yes |
| Multiple IP addresses | Yes | Yes |
| Forwards packets between subnets | No (usually) | Yes (its purpose) |
| Example | A server with eth0 + eth1 | tekapo connecting Subnet 1 and 2 |
RFC stands for Request for Comments. Every TCP/IP protocol is formally defined in an RFC document published by the IETF (Internet Engineering Task Force).
Despite the modest name (“request for comments”), RFC documents are the official standards for internet protocols. They describe exactly how TCP, UDP, IP, ICMP, and every other protocol must behave. Implementations that follow the RFC are interoperable with each other.
When you write a socket application on Linux and it communicates correctly with a Windows or BSD server, it works because both sides follow the same RFC — the same agreed-upon rules for how data must be formatted and exchanged.
You can explore the internet concepts from this section directly in Linux using standard command-line tools and C code.
List network interfaces and their details:
/* List interfaces using getifaddrs() — POSIX */
#include <stdio.h>
#include <ifaddrs.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <string.h>
int main(void)
{
struct ifaddrs *ifap, *ifa;
if (getifaddrs(&ifap) == -1) {
perror("getifaddrs");
return 1;
}
printf("%-15s %-8s %s\n", "Interface", "Family", "Address");
printf("%-15s %-8s %s\n", "---------", "------", "-------");
for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
if (ifa->ifa_addr == NULL)
continue;
int family = ifa->ifa_addr->sa_family;
if (family == AF_INET) { /* IPv4 */
char addr[INET_ADDRSTRLEN];
struct sockaddr_in *sin = (struct sockaddr_in *)ifa->ifa_addr;
inet_ntop(AF_INET, &sin->sin_addr, addr, sizeof(addr));
printf("%-15s %-8s %s\n", ifa->ifa_name, "IPv4", addr);
}
}
freeifaddrs(ifap);
return 0;
}
Compile and run:
gcc -o list_iface list_iface.c
./list_iface
# Typical output on a Linux machine:
# Interface Family Address
# --------- ------ -------
# lo IPv4 127.0.0.1
# eth0 IPv4 192.168.1.10
# wlan0 IPv4 192.168.1.25
Shell commands to explore networking concepts:
# Show all interfaces and their IP addresses
ip addr show
# Show the routing table (which router handles which subnet)
ip route show
# Show interfaces with MTU (useful for Data-Link Layer section)
netstat -i
# Trace the path packets take through routers (traceroute = router visibility)
traceroute www.google.com
# Check if a host is reachable (uses ICMP)
ping -c 3 8.8.8.8
# Show ARP table (hardware addresses mapped to IP addresses)
arp -n
Check if your machine is multihomed:
#include <stdio.h>
#include <ifaddrs.h>
#include <netinet/in.h>
int main(void)
{
struct ifaddrs *ifap, *ifa;
int count = 0;
getifaddrs(&ifap);
for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
if (ifa->ifa_addr == NULL) continue;
if (ifa->ifa_addr->sa_family == AF_INET) {
/* Skip loopback */
if (strncmp(ifa->ifa_name, "lo", 2) != 0)
count++;
}
}
freeifaddrs(ifap);
if (count > 1)
printf("This host is MULTIHOMED: %d IPv4 interfaces\n", count);
else
printf("Single interface host: %d IPv4 interface\n", count);
return 0;
}
Next: Protocol Layers & Encapsulation → Part 3: Data-Link Layer
