Network models · Fundamentals · Module 1
Layers: the OSI and TCP/IP models · page 2 of 3
Show topologyHide topology
Four devices in a column, joined by three cables. At the top the host H1: its eth0, address ending .10, is cabled to the switch SW1’s Et0/1. SW1’s Et0/0 is cabled to the router R1’s Et0/0, address ending .1. Both of SW1’s cables are one network, 10.0.1.0/24, written on each of them; SW1 itself has no address. R1’s Et0/1, address ending .1, is cabled to the host H2 at the bottom, its eth0 ending .20, in the network 10.0.2.0/24, written on that cable. A legend explains the short forms.
How it works
One line of text through the layers
R1 sends “hello from R1” to the program on H2. What does each layer do with it on the way?
The text goes down R1’s layers one at a time, from the application layer to the physical layer, and each layer hands its result to the layer below. The bits cross the cable, and on H2 the layers work the other way, from the bottom up, until the program gets the text (Figure 1.3).
Can you see the layers at work on R1? With debug ip packet detail on, R1 prints lines for the packets it sends or receives itself, port numbers included, and it printed such lines while it sent the text.
Step 1 of 6
R1’s telnet program has the text “hello from R1” for the program on port 2001 on H2.
Step 2 of 6
The transport layer adds which program: port 2001 on H2. R1’s line shows it as dst=2001.
Step 3 of 6
The network layer adds the source and destination IP addresses, 10.0.2.1 and 10.0.2.20, and picks the way out. R1’s line shows them as s=10.0.2.1 and d=10.0.2.20 (Ethernet0/1).
Next, the data link layer needs an address that works only within this one network. Which one?
- H2’s own address on this link, the address of its interface eth0. (Correct): H2 is on R1’s link, so the next device is H2 itself.
- H2’s address across networks, 10.0.2.20.: 10.0.2.20 is already in the header the network layer added, one layer up.
- The number of the program on H2, port 2001.: The port went into the transport layer’s header two steps earlier.
- R1’s address as the sender, 10.0.2.1.: 10.0.2.1 names the sender, not the next device, and it sits in the network layer’s header.
Step 4 of 6
The data link layer addresses the next device on this link.
Step 5 of 6
The physical layer sends it all as bits out of Ethernet0/1, onto the cable to H2.
Step 6 of 6
H2’s layers undo the same steps from the bottom. Each checks only its own part, and the program on port 2001 gets the text.
Two columns of layers: R1 on the left, H2 on the right, each with Application, Transport, Network, Data link and Physical from top to bottom. A cable joins the two physical layers, from R1’s Et0/1 to H2’s eth0. Step by step, arrows go down R1’s column, one layer at a time, and the current layer is drawn in the accent color; each step’s caption says what that layer adds: the text, then port 2001, then the two addresses 10.0.2.1 and 10.0.2.20, then H2 on this link, then bits on the cable. An arrow beside the cable then points from R1 to H2. In the last step, arrows go up H2’s column from Physical to Application.
telnet program has the text “hello from R1” for the program on port 2001 on H2.Debug line at this step TCP src=42805, dst=2001, seq=3850762891, ack=3177062388, win=32764 ACK PSHThe transport layer adds which program: port 2001 on H2. R1’s line shows it as dst=2001.Debug line at this stepIP: s=10.0.2.1 (local), d=10.0.2.20 (Ethernet0/1), len 55, sendingThe network layer adds the source and destination IP addresses, 10.0.2.1 and 10.0.2.20, and picks the way out. R1’s line shows them as s=10.0.2.1 and d=10.0.2.20 (Ethernet0/1).The data link layer addresses the next device on this link.The physical layer sends it all as bits out of Ethernet0/1, onto the cable to H2.H2’s layers undo the same steps from the bottom. Each checks only its own part, and the program on port 2001 gets the text.Answer here to see step 4, or tap “Skip, show me”.
Two of R1’s lines for the one piece of data that carries “hello from R1”. R1 prints the network layer’s line first, and the number beside each line is the step that added what it shows:
Lines appear as you step through.
R1#show logging | include IP:|TCP… 35 more lines (see Full output)3IP: s=10.0.2.1 (local), d=10.0.2.20 (Ethernet0/1), len 55, sending2 TCP src=42805, dst=2001, seq=3850762891, ack=3177062388, win=32764 ACK PSH… 31 more lines (see Full output)
Full output · 68 lines
R1#show logging | include IP:|TCPIP: tableid=0, s=10.0.2.1 (local), d=10.0.2.20 (Ethernet0/1) nexthop=10.0.2.20, routed via FIBIP: s=10.0.2.1 (local), d=10.0.2.20 (Ethernet0/1), len 52, sending TCP src=42805, dst=2001, seq=3850762890, ack=0, win=65535 SYNIP: s=10.0.2.1 (local), d=10.0.2.20 (Ethernet0/1), len 52, sending full packet TCP src=42805, dst=2001, seq=3850762890, ack=0, win=65535 SYNIP: s=10.0.2.20 (Ethernet0/1), d=10.0.2.1 (nil), len 52, input feature TCP src=2001, dst=42805, seq=3177062373, ack=3850762891, win=64240 ACK SYN, MCI Check(110), rtype 0, forus FALSE, sendself FALSE, mtu 0, fwdchk FALSEIP: s=10.0.2.20 (Ethernet0/1), d=10.0.2.1 (nil), len 52, rcvd 2 TCP src=2001, dst=42805, seq=3177062373, ack=3850762891, win=64240 ACK SYNIP: s=10.0.2.20 (Ethernet0/1), d=10.0.2.1 (nil), len 52, stop process pak for forus packet TCP src=2001, dst=42805, seq=3177062373, ack=3850762891, win=64240 ACK SYNIP: tableid=0, s=10.0.2.20 (Ethernet0/1), d=10.0.2.1 (Ethernet0/1) nexthop=10.0.2.1, routed via RIBIP: tableid=0, s=10.0.2.1 (local), d=10.0.2.20 (Ethernet0/1) nexthop=10.0.2.20, routed via FIBIP: s=10.0.2.1 (local), d=10.0.2.20 (Ethernet0/1), len 40, sending TCP src=42805, dst=2001, seq=3850762891, ack=3177062374, win=32768 ACKIP: s=10.0.2.1 (local), d=10.0.2.20 (Ethernet0/1), len 40, sending full packet TCP src=42805, dst=2001, seq=3850762891, ack=3177062374, win=32768 ACKIP: tableid=0, s=10.0.2.1 (local), d=10.0.2.20 (Ethernet0/1) nexthop=10.0.2.20, routed via FIBIP: s=10.0.2.1 (local), d=10.0.2.20 (Ethernet0/1), len 40, sending TCP src=42805, dst=2001, seq=3850762891, ack=3177062374, win=32768 ACKIP: s=10.0.2.1 (local), d=10.0.2.20 (Ethernet0/1), len 40, sending full packet TCP src=42805, dst=2001, seq=3850762891, ack=3177062374, win=32768 ACKIP: s=10.0.2.20 (Ethernet0/1), d=10.0.2.1 (nil), len 54, input feature TCP src=2001, dst=42805, seq=3177062374, ack=3850762891, win=502 ACK PSH, MCI Check(110), rtype 0, forus FALSE, sendself FALSE, mtu 0, fwdchk FALSEIP: s=10.0.2.20 (Ethernet0/1), d=10.0.2.1 (nil), len 54, rcvd 2 TCP src=2001, dst=42805, seq=3177062374, ack=3850762891, win=502 ACK PSHIP: s=10.0.2.20 (Ethernet0/1), d=10.0.2.1 (nil), len 54, stop process pak for forus packet TCP src=2001, dst=42805, seq=3177062374, ack=3850762891, win=502 ACK PSHIP: tableid=0, s=10.0.2.20 (Ethernet0/1), d=10.0.2.1 (Ethernet0/1) nexthop=10.0.2.1, routed via RIBIP: tableid=0, s=10.0.2.1 (local), d=10.0.2.20 (Ethernet0/1) nexthop=10.0.2.20, routed via FIBIP: s=10.0.2.1 (local), d=10.0.2.20 (Ethernet0/1), len 40, sending TCP src=42805, dst=2001, seq=3850762891, ack=3177062388, win=32764 ACKIP: s=10.0.2.1 (local), d=10.0.2.20 (Ethernet0/1), len 40, sending full packet TCP src=42805, dst=2001, seq=3850762891, ack=3177062388, win=32764 ACKIP: tableid=0, s=10.0.2.1 (local), d=10.0.2.20 (Ethernet0/1) nexthop=10.0.2.20, routed via FIBIP: s=10.0.2.1 (local), d=10.0.2.20 (Ethernet0/1), len 55, sending TCP src=42805, dst=2001, seq=3850762891, ack=3177062388, win=32764 ACK PSHIP: s=10.0.2.1 (local), d=10.0.2.20 (Ethernet0/1), len 55, sending full packet TCP src=42805, dst=2001, seq=3850762891, ack=3177062388, win=32764 ACK PSHIP: s=10.0.2.20 (Ethernet0/1), d=10.0.2.1 (nil), len 40, input feature TCP src=2001, dst=42805, seq=3177062388, ack=3850762906, win=502 ACK, MCI Check(110), rtype 0, forus FALSE, sendself FALSE, mtu 0, fwdchk FALSEIP: s=10.0.2.20 (Ethernet0/1), d=10.0.2.1 (nil), len 40, rcvd 2 TCP src=2001, dst=42805, seq=3177062388, ack=3850762906, win=502 ACKIP: s=10.0.2.20 (Ethernet0/1), d=10.0.2.1 (nil), len 40, stop process pak for forus packet TCP src=2001, dst=42805, seq=3177062388, ack=3850762906, win=502 ACKIP: tableid=0, s=10.0.2.20 (Ethernet0/1), d=10.0.2.1 (Ethernet0/1) nexthop=10.0.2.1, routed via RIBIP: tableid=0, s=10.0.2.1 (local), d=10.0.2.20 (Ethernet0/1) nexthop=10.0.2.20, routed via FIBIP: s=10.0.2.1 (local), d=10.0.2.20 (Ethernet0/1), len 40, sending TCP src=42805, dst=2001, seq=3850762906, ack=3177062388, win=32768 ACKIP: s=10.0.2.1 (local), d=10.0.2.20 (Ethernet0/1), len 40, sending full packet TCP src=42805, dst=2001, seq=3850762906, ack=3177062388, win=32768 ACKIP: tableid=0, s=10.0.2.1 (local), d=10.0.2.20 (Ethernet0/1) nexthop=10.0.2.20, routed via FIBIP: s=10.0.2.1 (local), d=10.0.2.20 (Ethernet0/1), len 40, sending TCP src=42805, dst=2001, seq=3850762906, ack=3177062388, win=32768 ACK PSH FINIP: s=10.0.2.1 (local), d=10.0.2.20 (Ethernet0/1), len 40, sending full packet TCP src=42805, dst=2001, seq=3850762906, ack=3177062388, win=32768 ACK PSH FINIP: s=10.0.2.20 (Ethernet0/1), d=10.0.2.1 (nil), len 40, input feature TCP src=2001, dst=42805, seq=3177062388, ack=3850762907, win=502 ACK FIN, MCI Check(110), rtype 0, forus FALSE, sendself FALSE, mtu 0, fwdchk FALSEIP: s=10.0.2.20 (Ethernet0/1), d=10.0.2.1 (nil), len 40, rcvd 2 TCP src=2001, dst=42805, seq=3177062388, ack=3850762907, win=502 ACK FINIP: s=10.0.2.20 (Ethernet0/1), d=10.0.2.1 (nil), len 40, stop process pak for forus packet TCP src=2001, dst=42805, seq=3177062388, ack=3850762907, win=502 ACK FINIP: tableid=0, s=10.0.2.20 (Ethernet0/1), d=10.0.2.1 (Ethernet0/1) nexthop=10.0.2.1, routed via RIBIP: tableid=0, s=10.0.2.1 (local), d=10.0.2.20 (Ethernet0/1) nexthop=10.0.2.20, routed via FIBIP: s=10.0.2.1 (local), d=10.0.2.20 (Ethernet0/1), len 40, sending TCP src=42805, dst=2001, seq=3850762907, ack=3177062389, win=32768 ACKIP: s=10.0.2.1 (local), d=10.0.2.20 (Ethernet0/1), len 40, sending full packet TCP src=42805, dst=2001, seq=3850762907, ack=3177062389, win=32768 ACK
Key idea
Down on the sender, up on the receiver: the header that layer 4 adds on R1 is read by layer 4 on H2.
Use the rule: a sender’s layers work from the top down.
Verify
Check each layer on R1
R1 reaches the program on H2. How do you see, layer by layer, that each part works?
Start at the bottom, with R1’s interface toward H2. show interfaces with the interface name prints 27 lines for this one interface.
R1’s interface toward H2, when everything works.
Tap a line, or “Not in the output”, then submit.
Find the line that shows the layer-3 setting of this interface.
R1#show interfaces Ethernet0/1… 2 more lines (see Full output)… 21 more lines (see Full output)
- Layers 1 and 2: both parts read
up. - The interface’s hardware and its address on the link: layer 2.
- The IP address and mask, 10.0.2.1/24: layer 3.
Encapsulation ARPA: the data link layer’s format on this link, layer 2.
Full output · 27 lines
R1#show interfaces Ethernet0/1Ethernet0/1 is up, line protocol is up Hardware is AmdP2, address is aabb.cc00.0910 (bia aabb.cc00.0910) Internet address is 10.0.2.1/24 MTU 1500 bytes, BW 10000 Kbit/sec, DLY 1000 usec, reliability 255/255, txload 1/255, rxload 1/255 Encapsulation ARPA, loopback not set Keepalive not set ARP type: ARPA, ARP Timeout 04:00:00 Last input 00:00:00, output 00:00:00, output hang never Last clearing of "show interface" counters 00:01:14 Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0 Queueing strategy: fifo Output queue: 0/40 (size/max) 5 minute input rate 1000 bits/sec, 2 packets/sec 5 minute output rate 1000 bits/sec, 2 packets/sec 42 packets input, 4772 bytes, 0 no buffer Received 0 broadcasts (0 IP multicasts) 0 runts, 0 giants, 0 throttles 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored 0 input packets with dribble condition detected 42 packets output, 4772 bytes, 0 underruns Output 0 broadcasts (0 IP multicasts) 0 output errors, 0 collisions, 0 interface resets 0 unknown protocol drops 0 babbles, 0 late collision, 0 deferred 0 lost carrier, 0 no carrier 0 output buffer failures, 0 output buffers swapped out
The first line holds two states. Ethernet0/1 is up says that the interface hardware is active, a layer-1 state. line protocol is up says that the software that runs the link’s protocol considers the line usable; that is a layer-2 state, the data link layer.
R1 on another day, the same interface. Which layers are fine, and what differs from the topology?
R1#show interfaces Ethernet0/11Ethernet0/1 is up, line protocol is up Hardware is AmdP2, address is aabb.cc00.0910 (bia aabb.cc00.0910)2 Internet address is 10.0.2.1/30… 24 more lines (see Full output)
- Layers 1 and 2:
upandup, as before. - The same address, but /30 where the topology shows 10.0.2.0/24. The layer-3 setting has changed.
The number after the slash is the prefix length, the number of ones in the mask.
Full output · 27 lines
R1#show interfaces Ethernet0/1Ethernet0/1 is up, line protocol is up Hardware is AmdP2, address is aabb.cc00.0910 (bia aabb.cc00.0910) Internet address is 10.0.2.1/30 MTU 1500 bytes, BW 10000 Kbit/sec, DLY 1000 usec, reliability 255/255, txload 1/255, rxload 1/255 Encapsulation ARPA, loopback not set Keepalive not set ARP type: ARPA, ARP Timeout 04:00:00 Last input 00:00:25, output 00:00:20, output hang never Last clearing of "show interface" counters 00:05:39 Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0 Queueing strategy: fifo Output queue: 0/40 (size/max) 5 minute input rate 0 bits/sec, 0 packets/sec 5 minute output rate 0 bits/sec, 0 packets/sec 210 packets input, 22496 bytes, 0 no buffer Received 0 broadcasts (0 IP multicasts) 0 runts, 0 giants, 0 throttles 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored 0 input packets with dribble condition detected 243 packets output, 24566 bytes, 0 underruns Output 12 broadcasts (0 IP multicasts) 0 output errors, 0 collisions, 1 interface resets 0 unknown protocol drops 0 babbles, 0 late collision, 0 deferred 0 lost carrier, 0 no carrier 0 output buffer failures, 0 output buffers swapped out
show ip interface brief shows layers 1 and 2 for every interface at once, here in the working network. “Status” is the interface hardware state, layer 1, and “Protocol” is the line protocol state, layer 2.
- Ethernet0/1, toward H2: Status
up(layer 1), Protocolup(layer 2).
Full output · 5 lines
R1#show ip interface briefInterface IP-Address OK? Method Status ProtocolEthernet0/0 10.0.1.1 YES TFTP up up Ethernet0/1 10.0.2.1 YES TFTP up up Ethernet0/2 unassigned YES unset administratively down down Ethernet0/3 unassigned YES unset administratively down down
Scroll sideways to see the whole output
In this network, the first line of show interfaces on R1 read one of two ways:
| State | Means | Look next |
|---|---|---|
up, line protocol is up | layers 1 and 2 work on this interface | the Internet address line, then a ping to the far host |
administratively down, line protocol is down | the interface was turned off with shutdown; no layer can work on it | show running-config interface for that interface |
| Command | What it does | Default | Where you see the result |
|---|---|---|---|
shutdown / no shutdown | turns the interface off / on again; one interface only | shut down on R1’s unused interfaces, Et0/2 and Et0/3 | the first line of show interfaces |
Layer 3 crosses the devices in between, so its test must reach the far host. ping sends small test packets to an address and counts the replies, and each ! is a reply, each . a test packet that got none. Your own computer has a ping command too, though its output looks different.
R1#ping 10.0.2.20Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 10.0.2.20, timeout is 2 seconds:1!!!!!2Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
- A reply for every test packet.
Success rate is 100 percent (5/5): layer 3 gets through from R1 to H2.
The layers above layer 3 are proven only when H2’s transport layer or a program answers. With a port after the address, telnet connects to the port you give and shows what comes back.
R1#telnet 10.0.2.20 20011Trying 10.0.2.20, 2001 ... Open2hello from H2
Open: a transport-layer connection to port 2001 on H2.hello from H2: the program’s own data arrived, the application layer.
Key idea
Up and up: layers 1 and 2. A ping answered: layer 3. The program’s answer: the layers above.