Wiki DE Start in the browser

Wiki › Protocols

IPv4

Addresses, masks and the IPv4 header: how a packet finds its destination across many networks, with TTL, checksum and private addresses.

Layer
3 (Vermittlung)
Standard
RFC 791, RFC 1918, RFC 5737
See an example
See demo

Addresses

An IPv4 address has 32 bits, written as four numbers from 0 to 255: 192.168.1.10. Together with the mask (255.255.255.0 or /24) it says which network a device is in (Subnetting and VLSM).

RangePurpose
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16private, only in your own network (RFC 1918)
100.64.0.0/10provider NAT (CGNAT)
127.0.0.0/8the device itself (loopback)
169.254.0.0/16self-assigned when DHCP is missing
192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24for examples and documentation (RFC 5737)

The IPv4 header

Without options the header is 20 bytes long, five rows of 32 bits. The values come from a real packet of the simulation.

IPv4Packet · RFC 791, RFC 2474, RFC 3168
0481216202428
Version4 bits4
IHL4 bits5
DSCP6 bits0
ECN2 bits0
Total length16 bits140
Identification16 bits0x0006
Flags3 bitsDF
Fragment offset13 bits0
TTL8 bits64
Protocol8 bits6
Header checksum16 bits0x9aa7
Source IP32 bits192.168.10.100
Destination IP32 bits192.168.20.10
Options0–40 bytes
Payload≤ 65515 bytes120 Byte
Each row has 32 bits (4 bytes), bit 0 on the left, as the RFCs draw their headers. Dashed: variable or optional. Point at a field for an explanation.
FieldLengthExample valueMeaning
Version4 bits44 for IPv4.
IHL4 bits5Internet header length in 32-bit words: 5 = 20 bytes without options.
DSCP6 bits0Differentiated services: traffic class for quality of service (RFC 2474), 0 = best effort.
ECN2 bits0Explicit congestion notification: routers signal congestion without dropping packets (RFC 3168).
Total length16 bits (2 bytes)140Length of header and payload in bytes, at most 65,535.
Identification16 bits (2 bytes)0x0006Packet number; all fragments of a packet carry the same one.
Flags3 bitsDFBit 0 reserved, DF = don't fragment, MF = more fragments follow.
Fragment offset13 bits0Position of the fragment in the original packet, in steps of 8 bytes.
TTL8 bits64Time to live: each router subtracts 1; at 0 the packet is dropped (ICMP time exceeded).
Protocol8 bits6What is inside: 1 ICMP, 6 TCP, 17 UDP, 50 ESP, 89 OSPF.
Header checksum16 bits (2 bytes)0x9aa7Checksum over the header only (RFC 1071); each router recalculates it because of the TTL.
Source IP32 bits (4 bytes)192.168.10.100Sender, unchanged along the whole path (except with NAT).
Destination IP32 bits (4 bytes)192.168.20.10Destination, routers decide the path by it.
Options (optional)0–40 bytesRarely used (e.g. record route); IHL is then greater than 5.
Payload≤ 65515 bytes120 ByteThe segment or message of the next layer (TCP, UDP, ICMP …).
Values: Real frame from the demo “DNS, TCP and HTTP” (no. 36, 158 bytes), exactly as the packet list in leyoNET shows it.

On the way through several networks the Ethernet header changes at every router, the IP header stays; only TTL and checksum change.

Typical mistakes

  • Wrong mask: two devices think they are in the same network but are not (or vice versa).
  • Gateway outside the network: leyoNET allows the entry but warns; this makes troubleshooting tasks possible.
  • Duplicate address: two devices with the same address in the same network; leyoNET marks both with a red exclamation mark.

How to do it in leyoNET

The same text as in the app’s help (F1 key).

IP addresses

Every device needs an IP address and a mask (e.g. 192.168.1.10/24). The mask says which part is the network. If the destination is in another network, the device sends the packet to its gateway (the router). The DNS server turns names into addresses.

See also Subnetting, Private and public addresses and IP calculator.

Values are saved as soon as you leave the field (Tab, Enter or clicking elsewhere, including another device). If the mask is missing, leyoNET fills in the usual mask of the address class (e.g. /24 for 192.168.x.x); you can change it at any time.

Duplicate addresses

If two devices in the same network have the same IP address, a red ! appears on the device, the address turns red and the form shows a warning. In the simulation, addresses obtained via DHCP count too.

The same network means: connected through cables, switches, access points or modems without a router in between. Behind different routers (e.g. two home networks with 192.168.1.1) the same private address is fine.

See an example

  • Demo “Default gateway” in leyoNETDemo “Default gateway” in leyoNET
    Slow motion This is how it looks in the simulation: every dot is a frame on the cable.
    Default gateway

    Two subnets connected by a router.

    PC 1 sees that the target is in another network and sends the packet to its router. The TTL drops by one.

    Watch live Project file

“Watch live” opens the network in leyoNET, the simulation runs in a loop. In the app you find it under File → Demo networks, with a step-by-step tour.

Practise

  • ★★☆☆☆ Two networks with a router · 4 goals · Worksheet (German)
  • ★☆☆☆☆ Who has the address twice? · 3 goals · Worksheet (German)
  • ★☆☆☆☆ UE03 Router01 – Task 1: one network, two switches · 6 goals · Worksheet (German)
  • ★☆☆☆☆ UE03 Router01 – Task 2: two networks on the same switches · 6 goals · Worksheet (German)

In leyoNET under Tools → Exercise catalogue. Every exercise checks itself.

What leyoNET simplifies

ProtocolLayerSimplification in the simulation
IPv43No fragmentation (MSS 1460 prevents it), no options

Standards

  • RFC 791 – Internet Protocol
  • RFC 1918 – Address Allocation for Private Internets
  • RFC 5737 – IPv4 Address Blocks Reserved for Documentation

Read on

Found a mistake or have an idea? Source of this page on GitHub.