Internet Protocol (IP): How it works and why it's key

  • IP offers a best-effort, connectionless datagram delivery service, relying on TCP or other protocols for reliability.
  • IP addressing, along with network masks, routing tables, and metrics, allows heterogeneous networks to be interconnected on a global scale.
  • The IP header defines fields for fragmentation, TTL, quality of service, and selection of the encapsulated transport protocol.
  • The transition from IPv4 to IPv6 greatly expands the address space and improves efficiency, security, and support for new services.

Internet Protocol (IP) Diagram

When you connect to the Internet from your mobile phone, home laptop, or office computer, all the data you send and receive travels following a set of very strict rules known as the Internet Protocol (IP)Although you may not see it, every website you visit, every email you send, or every video call you make depends on it to ensure that the information reaches (more or less) where it needs to go.

Far from being something magical, IP is a very well-thought-out system that combines addressing, packet routing, and data fragmentation So that different devices, with different operating systems and connected by very diverse networks, can communicate with each other as if they were all part of a single global network. We're going to break it down step by step so you understand what it does, how it does it, and why it's so crucial to today's network.

What is the Internet Protocol (IP) and what function does it have?

The Internet protocol, or simply IP (Internet Protocol)It is the cornerstone of the TCP/IP protocol suite. Its mission is to handle the transmission of data in the form of packets between interconnected devices, without the need to establish a prior connection and without guaranteeing that everything will arrive perfectly.

In practice, IP acts as a kind of datagram “courier company”It receives blocks of information (datagrams), adds a header with control data (mainly source and destination addresses) and passes them on to the network so that they hop from router to router until they reach the destination machine, if everything goes well.

A key feature is that it is a protocol non-connection-oriented and best effortThis means there is no prior dialogue between source and destination to "negotiate" communication, and IP will do its best to deliver the packets, but without promising anything: they may be lost, arrive duplicated, out of order, or damaged.

Reliability, flow control, or error recovery are not provided by IP, but higher-level protocols such as TCPIP is limited to offering a basic datagram delivery service over a network that can be very heterogeneous at the physical level (fiber, WiFi, Ethernet, wireless links of all kinds, etc.).

IP also hides the complexity of the physical networkThis provides upper-layer protocols with a unified view of the "virtual network." As a result, applications and services don't need to know whether there are ten or one hundred routers between the source and destination, or what technology each segment uses.

Operation and addresses of the IP protocol

IP within TCP/IP and its relationship with other protocols

On the Internet, people almost always talk about the group. TCP / IPBecause in many services they are used together: IP at the network layer and TCP at the transport layer. However, the Internet protocol suite is much broader: there are more than one hundred different protocols that coexist and they rely on IP.

IP is standardized as STD 5This specification also includes ICMP (Internet Control Message Protocol, used for error and diagnostic messages, such as ping messages) and IGMP (Internet Group Management Protocol, for managing multicast groups). Its status is "required," meaning that any serious TCP/IP stack must implement it.

Among the documents that define IP, the following stand out: RFCs 791, 950, 919 and 922with subsequent updates, for example in RFC 1349 for the Type of Service (TOS) field. These RFCs describe the datagram format, how fragmentation is handled, what the header fields mean, etc.

The most relevant transport protocols that rely on IP are TCP (Transmission Control Protocol) and UDP (User Datagram Protocol)TCP offers a reliable, connection-oriented channel, ideal for applications that require integrity (such as the web or email). UDP, on the other hand, is lightweight and lacks error control at the transport level, making it widely used for real time applications (audio, video, online games) or protocols such as DNS, and measurement tools such as iperf3 in multi-thread mode They allow you to evaluate network performance.

In addition to TCP and UDP, IP can encapsulate other protocols such as SCTP (Stream Control Transmission Protocol), used in some advanced contexts (for example, signaling or certain telecommunications services) and which also offers reliable transport characteristics but with multipath or multi-stream capabilities.

IP protocol versions: IPv4 and IPv6

The most well-known and historically widespread version is IPv4which uses 32-bit addresses. This allows for just over four billion theoretical addresses, a number that fell short years ago due to the explosion of connected devices.

To overcome this limitation, a system was designed IPv6, successor to IPv4, which uses 128-bit addresses, a gigantic space capable of holding a virtually inexhaustible number of nodesIPv6 also introduces improvements such as stateless autoconfiguration, a simpler and more extensible header scheme, better native support for security, and new flow control and quality of service capabilities.

In IP history, versions 0 through 3 were either reserved or never deployed, while version 5 It was used for an experimental protocol. Other version numbers were assigned to research projects, but only IPv4 and IPv6 have become widespread as the basis of the Internet.

Today, both coexist: much of the global network still operates with IPv4, relying on tricks such as NAT (Network Address Translation)While IPv6 is being deployed gradually, especially in operators, large companies and cloud services.

IP addresses, types and related concepts

An IP address It is a numerical identifier assigned to each network interface of a device within a network that uses the Internet Protocol. It does not identify the entire device, but rather the specific interface: if a device has both Ethernet and Wi-Fi enabled, each of those interfaces will have its own IP address.

It is important not to confuse the IP address with the MAC addressThe MAC address is a physical identifier, engraved by the manufacturer on the network card, and it typically doesn't change throughout its lifespan. The IP address, on the other hand, is logical and can change when switching networks, restarting the router, or reconfiguring the infrastructure.

IP addresses are usually divided into two parts: network portion and host portionThe network part identifies which network the device belongs to (and which link protocol the devices share on that physical medium), while the host part distinguishes each machine within that network.

On a practical level, there are Public IPs and private IPsA public IP address is one that is advertised on the internet and allows your home network or server to be located from anywhere on the global network. Private IP addresses, on the other hand, are used within local networks (such as your home or a company's internal network) and are not directly routable over the internet.

Furthermore, an address can be static or dynamicWhen you connect to the internet at home, your provider usually assigns you a public IP address dynamically using a protocol such as DHCP (Dynamic Host Configuration Protocol)That IP address can change between reconnections. In contrast, services that must be always available (web servers, mail servers, DNS servers, public FTP servers, etc.) usually use fixed or static IP addresses, which makes it easier for other systems to find them without surprises.

To make life easier for humans, who are quite bad at remembering long numbers, IP addresses can be associated with domain namesThe Domain Name System (DNS) translates names like "example.com" into their corresponding IP addresses. Machines only need the number; we prefer easy-to-remember words.

Another relevant concept is the net maskA subnet mask is a value that indicates which part of the IP address corresponds to the network and which to the host. With the subnet mask, devices can decide whether a packet should be sent within the local network or forwarded to a router to reach an external network.

The machine itself also contains local loopback interface (loopback), represented in IPv4 by the address 127.0.0.1. It allows a computer to communicate with itself using the same protocols it would use to talk to others, very useful for testing, development and debugging.

How IP works: datagrams, fragmentation, and routing

When an application wants to send data across the network (for example, a web browser), the transport protocol it uses typically TCPdivide that information into smaller segments and passes them to the network layer to be packaged as IP datagrams.

IP defines the datagram formatA header with multiple control fields and a data area containing the contents of the higher-level protocol (TCP, UDP, ICMP, etc.). Unlike other protocols, IP does not require a prior exchange of control messages before sending the payload.

If the datagram size is greater than the MTU (Maximum Transmission Unit) accepted by the physical link through which it must circulate, IP may fragment That datagram is divided into several smaller pieces. Each fragment travels across the network with its own IP header, and at the final destination they are reassembled to reconstruct the original datagram.

This fragmentation can occur at various points along the path, not just at the source. Each router that finds a link with a lower MTU can re-fragment, respecting the identification information and the fragment offset. Reassembly, however, is performed only on the destination host to avoid overloading the routers with intermediate work.

If one of the fragments is lost, the entire datagram is considered lost, since IP does not implement acknowledgments or retransmissionsThe transport protocol (usually TCP) will detect the gaps in the data sequence and request the missing information again.

Throughout this journey, each IP datagram traverses multiple intermediate networks and encounters routersThese devices are specialized in receiving packets through an interface, looking at the destination IP address, and forwarding them through the best available outgoing interface, based on their routing table.

Header of an IP datagram and main fields

The IP datagram includes a header with a minimum size of 20 bytes This encodes all the information necessary for the routers and the destination host to process it correctly. Some of the most important fields are:

  • Version: indicates whether the datagram is IPv4 or IPv6.
  • Header length: specifies how many 32-bit words the header occupies, not counting the data.
  • Type of Service (TOS) / DSCP: It is used to express the quality of service requirements (delay, performance, reliability, cost, etc.) of the traffic.
  • Total length: full length of the datagram (header + data) in bytes.
  • ID: a number that allows grouping fragments belonging to the same datagram.
  • Flags and fragment offset: They control whether fragmentation is allowed and in what position each fragment is placed.
  • Time to Life (TTL): counter that is decremented at each router hop to prevent packets from circulating indefinitely.
  • Protocol: indicates which higher-level protocol the data should be delivered to (TCP, UDP, ICMP, OSPF, etc.).
  • Header checksum: checksum that verifies the integrity of the header itself.
  • Source and destination IP addresses: They identify the intended sender and receiver of the datagram.
  • Options and filling: Optional variable-length field for advanced functionality, followed by padding bytes to align the header to 32 bits.

El protocol field This is what allows IP to deliver content to the appropriate module in the transport or control layer. For example, the value 6 is reserved for TCP, 17 for UDP, 1 for ICMP, 89 for OSPF (Open Shortest Path First), and so on, according to the official list of assigned protocol numbers.

El header checksum It is calculated as the one's complement of the sum of all 16-bit words in the header, assuming that the checksum field itself is zero during the calculation. If the result does not match when a datagram is received, it is assumed that at least one bit in the header is corrupted and the packet is discarded.

El TTLAlthough formally it represents maximum lifetime in seconds, in practice it's managed as a hop counter: each router decrements it by one, and if it reaches zero, it discards the packet and usually sends an ICMP error message to the source. This prevents a misconfigured routing loop from flooding the network with endless traffic.

The IP options Options allow you to extend the protocol without changing its basic structure. Each option has a format with type, length, and data, and can control aspects such as route logging, timestamps, security, or special handling of certain packets. Not all systems generate options, but all must be able to process them if they appear.

Routing, routing tables, and metrics

Each host and each router participating in an IP network maintains a Routing tableThis table records the correspondences between destination networks and the next hop needed to reach them. It may contain:

  • Direct routes: networks to which the equipment is physically connected.
  • Indirect routes: networks that are reached through one or more intermediate routers.
  • Default path: generic exit for any destination that does not match the routes above.

The process of choosing where to send a datagram is called routingEach time a team has to forward a package, it looks at the destination address, consults its routing table, and decides on the best available option.

To evaluate how “good” a route is, routing protocols use the concept of metricsAccording to the protocol, this metric can be based on distance (number of hops), delay, cost, available bandwidth, link reliability, or a weighted combination of several factors.

The ideal goal is to achieve a optimal routingThat is, selecting paths that minimize the chosen metric (distance, cost, delay, etc.). In practice, the network is constantly changing, and routing protocols (such as RIP, IGRP, EIGRP, OSPF, etc.) are responsible for exchanging information between routers to adapt routing tables to real-world conditions.

This entire process is interactive: each router The routing algorithm applied to the destination IP address is reapplied to the datagram as it passes through, and a new forwarding decision is made, until the packet finally reaches its target host, where it is delivered to the transport layer or the corresponding application.

Stateless connection, encapsulation, and best-effort service

IP is considered a protocol statelessThis means that the network does not maintain persistent information about “sessions” or “connections” between two endpoints: each packet is treated independently, using only the information contained in its header.

Thanks to its stateless design, IP scales very well: There's no need to save context for every communicationThis reduces memory and complexity in routers and intermediate equipment. The price to pay is that the responsibility for ordering, securing, and validating data falls to higher layers.

IP provides a service of best effort (Best effort): attempts to deliver packets, but without guarantees of success, order, or non-duplication. There may be losses, errors, variable delays, etc. That's why transport protocols like TCP handle adding acknowledgments, flow control, retransmission of lost segments, etc.

Another key feature of the layered model is the encapsulationThe data generated by an application is first encapsulated in transport layer units (TCP segments or UDP datagrams), which in turn are encapsulated within IP datagrams; these are included in link layer frames (e.g., Ethernet), and finally converted into physical signals at the lowest layer.

This encapsulation mechanism allows that Routers only worry about the IP header to make routing decisions without needing to understand the underlying application or transport protocol. Each layer focuses on its own responsibilities, making the system modular and easier to evolve.

IP, mobility and support for modern services

The ubiquity of the IP protocol has made it the basis for services as diverse as Web browsing, email, VoIP, streaming, or instant messagingHTTP and HTTPS are built over TCP/IP to serve web pages; SMTP, IMAP, or POP3 handle email; SIP and RTP encapsulate audio and video over IP for calls and video conferences; XMPP, WebSocket, or the MQTT protocol They allow real-time messaging.

In today's world, where devices are constantly switching networks (mobile, home WiFi, office WiFi…), IP also integrates complementary mechanisms and protocols that facilitate mobilityAmong them are Mobile IP (MIP) and address translation techniques such as NAT...or IPv6 neighbor discovery and address management protocols such as NDP, and carriers that integrate 5G and IoT for advanced services.

Additionally, some mechanisms and protocols (such as SCTP or certain IPv6 extensions) allow change route or interface while keeping connections activeThis improves the user experience on mobile devices and in scenarios with multiple links.

Security has also been gaining importance: extensions such as IPsec They provide authentication, integrity, and encryption at the network level, while flow control and traffic marking capabilities in IPv6 help to provide better quality of service to latency-sensitive communications, such as voice or video.

In short, the IP protocol has evolved from a simple and unreliable but very flexible design, into a robust, scalable and essential infrastructure which supports virtually all modern digital communications, from the most critical in businesses and data centers to the most everyday in our homes.

How to use iperf3 in multi-thread mode-0
Related article:
How to use iperf3 in multithreaded mode: a complete guide