Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

7.3 (5 of 8): The OSI and TCP/IP models

The whole lesson, free. Read it and have a go at the activities. To work the tasks and labs in the real lesson, press Start lab, with no account needed.

50 minutes

A quick check that you are not a bot, then your own lab opens on the interactive lesson.

Already have an account? Sign in

Sending a parcel

You send a gift to a friend in another country. You write a note. You put it in a box. You write the address on the box. A van takes it to a post office. A plane flies it. Another van brings it to your friend.

Nobody does the whole job. Each person does one small job. Then they pass the parcel on. Computers send data in the same way, in layers.

Key words

WordWhat it meansExample
EncryptionScrambling data so only the right people can read it.HTTPS
NetworkComputers joined to share data.The college network
RouterA device that joins networks and sends data the right way.A home router
PortA number that says which program on a computer gets the data.80 for a web page
ASCIIA code that gives each letter and symbol a number.A is 65

The cells students fill in are left blank in this preview.

More key words

WordWhat it meansExample
LayerOne level in a model, with one job.The transport layer
OSI modelA seven-layer model of how data moves across a network.Layers 1 to 7
TCP/IP modelThe four-layer model the internet is built on.Application, transport, internet, network
ProtocolA set of rules computers follow to talk to each other.HTTP
HeaderExtra information a layer adds to the front of the data.The address on the box
IP addressA number that names a device on a network.10.0.12.1
MAC addressA number built into a network card that names it.Six pairs of letters and numbers
FrameThe data with its last header added, ready to send.[Frame][IP][TCP]Hi
EthernetThe usual wired way to join computers in a building.The cable behind a desk PC
OSPFOpen shortest path first: routers share a map to find the best path.Routers in a large network
DNSDomain name system: it turns a name into an IP address.Finding a website
ARPAddress resolution protocol: it finds the MAC address for an IP address.Who has 10.0.12.1?

The cells students fill in are left blank in this preview.

Put the parcel jobs in order

Have a go

Put the parcel jobs in order

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Why use layers?

A layer does one job and talks to the layer above and below it. You can change one layer and leave the rest as it is.

For example, you can change from a cable to Wi-Fi. Only the bottom layers change. Your web browser does not notice.

The seven OSI layers

LayerNameIts jobExamples
7ApplicationGives network services to the program you useHTTP, HTTPS, FTP, SMTP, DNS
6PresentationChanges the format of data. Handles encryption and compression (making data smaller)TLS (the encryption behind HTTPS)
5SessionStarts, keeps and ends a conversation between two programsKeeping a video call connected until you hang up
4TransportBreaks data into parts and delivers them safelyTCP
3NetworkGives IP addresses and chooses the route across networksIP, OSPF
2Data linkMoves data between two devices that are joined by one cable or one radio link. Uses MAC addressesEthernet, Wi-Fi, switches
1PhysicalSends the 1s and 0s as electricity, light or radioEthernet cables, Wi-Fi radio, USB

The cells students fill in are left blank in this preview.

A way to remember the order

Tip

From layer 7 down to layer 1: "All People Seem To Need Data Processing". Application, Presentation, Session, Transport, Network, Data link, Physical. You can make your own sentence.

Quick check: the layers

Have a go

Quick check: the layers

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Match the layer to its job

Have a go

Loading…

Your answers are marked here and are not kept. A college account keeps every student’s marks.

The four TCP/IP layers

TCP/IP layerIts jobProtocolsOSI layers it covers
ApplicationServices for programs, formats and conversationsHTTP, HTTPS, FTP, SMTP, DNS, DHCP5, 6 and 7
TransportSplits data and delivers it safelyTCP4
InternetIP addresses and routes across networksIP, OSPF3
NetworkMoves data over the local cable or Wi-FiEthernet, Wi-Fi1 and 2

The cells students fill in are left blank in this preview.

The two models side by side

flowchart LR
  subgraph TCP["TCP/IP: four layers"]
    t4["Application"] --> t3["Transport"] --> t2["Internet"] --> t1["Network"]
  end
  subgraph OSI["OSI: seven layers"]
    o7["Application"] --> o6["Presentation"] --> o5["Session"] --> o4["Transport"] --> o3["Network"] --> o2["Data link"] --> o1["Physical"]
  end

Extra: More protocols on each layer

OSI layerMore examplesWhat they do
6 PresentationTLS, JPEG, ASCIITLS encrypts for HTTPS. JPEG and ASCII are formats for pictures and text.
5 SessionRPC, NetBIOSStart and keep a conversation between two programs
4 TransportUDP, portsUDP is fast, with no delivery check. A port picks the program that gets the data.
3 NetworkICMPCarries error messages and the ping test
2 Data linkARPFinds the MAC address that goes with an IP address

The cells students fill in are left blank in this preview.

Put the protocol on its layer

Have a go

Loading…

Your answers are marked here and are not kept. A college account keeps every student’s marks.

Try it: every layer adds a header

Code: python
message = "Goal!"
print(message)

for layer in ["TCP", "IP", "Frame"]:
    message = "[" + layer + "]" + message
    print(message)

# TCP is the transport layer. IP is the internet layer.
# Frame is the network layer in the TCP/IP model (the data link layer in OSI). Add your own layer and run it again.

Make a free account to save your work and track your progress.

Extra: Send one ping to the router

Command
sudo ip netns exec h1 ping -c 1 -W 1 10.0.12.1

A command for the lesson’s lab terminal. It is shown here and not run.

Extra: Read both kinds of address

Command
sudo ip netns exec h1 ip addr show

A command for the lesson’s lab terminal. It is shown here and not run.

Extra: See the address pair

Command
sudo ip netns exec h1 ip neigh

A command for the lesson’s lab terminal. It is shown here and not run.

Extra: Two addresses for one device

Important

In the second output, find the interface to-r1. Its link/ether line holds the MAC address: a data link address. Its inet line holds the IP address: a network layer address. One device has both. The last command showed the router and the MAC address that ARP learned for it.

Your turn: add and remove headers

A message goes down the layers. Each layer adds a label (a header) at the front.

  1. Write add_headers. It adds "[TCP]", then "[IP]", then "[Frame]". Each new label goes at the very front.
  2. Write remove_headers. The other computer takes the labels off in the opposite order.
  3. Press Run Tests to check.
Code: python
def add_headers(message):
    # Add three labels in front of the message, one at a time:
    # first "[TCP]", then "[IP]", then "[Frame]".
    # Each new label goes at the very front.
    # add_headers("Hi") gives "[Frame][IP][TCP]Hi".
    return message


def remove_headers(packet):
    # The other computer takes the labels off in the opposite order.
    # remove_headers("[Frame][IP][TCP]Hi") gives "Hi".
    return packet

Make a free account to save your work, or press Start lab to work through the whole lesson.

Key words crossword

Have a go

Loading…

Your answers are marked here and are not kept. A college account keeps every student’s marks.

Final check

Have a go

Final check

7 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Teach this lesson with your class

On a college account your students work the tasks and the labs as well, and every mark is kept for you.