impera Open Impera

A levels Computer Science · Networks and databases

The internet and TCP/IP

1The TCP/IP stack

Internet communication uses the TCP/IP protocol stack, which has four layers.

The TCP/IP stack. Going down, each layer wraps the data in its own header; the receiver removes them going up.

LayerJobProtocols
applicationprovides network services to applicationsHTTP, HTTPS, FTP, SMTP, IMAP, DNS
transportsplits data into numbered segments; checks delivery; port numbersTCP, UDP
internet (network)adds IP addresses; routes packets across networksIP
linksends frames across the physical network; MAC addressesEthernet, Wi-Fi

As data goes down the stack, each layer adds its own header (encapsulation). At the receiving end, each layer removes its header as the data goes up.

Check yourself

Which layer adds the source and destination IP addresses?

  • The link layer

  • The transport layer

  • The application layer

  • The internet layer

Show the answer

The internet layer

Routing.

2Packet switching

Data sent over the internet is split into packets. Each packet has:

  • a header: source and destination IP addresses, the packet's sequence number, the protocol and a time to live (hop limit);
  • the payload: the data itself;
  • a trailer: an error-checking value (checksum).

Each packet may take a different route through the network of routers, choosing the best path at that moment. At the destination, TCP puts the packets back in order using the sequence numbers, and asks again for any that are missing or corrupted.

Packet switchingCircuit switching
no dedicated path; packets share linksa dedicated path is set up for the whole call
efficient use of the networkthe path is reserved even when silent
routes around broken linksif the path breaks, the connection is lost
packets may arrive out of orderdata arrives in order

The time to live stops lost packets circling the network forever: each router reduces it by 1, and the packet is dropped at 0.

Check yourself

Why does each packet carry a sequence number?

  • To choose the best route for the packet to take

  • To set the packet's time to live

  • So the receiver can put the packets back in the right order

  • To encrypt the data carried in each packet

Show the answer

So the receiver can put the packets back in the right order

They may arrive out of order.

3IP addresses

An IP address identifies a device on a network.

  • IPv4 addresses are 32 bits, written as four numbers from 0 to 255, such as 192.168.1.37. That gives about 4.3 billion addresses, which is not enough.
  • IPv6 addresses are 128 bits, written in hexadecimal, giving about 3.4 × 10³⁸ addresses.
  • Private addresses (such as 192.168.x.x) are used inside a LAN. Network address translation (NAT) on the router lets many private devices share one public address on the internet.
  • DHCP gives devices an IP address automatically when they join a network.

A subnet mask shows which part of an address is the network and which part is the host.

Worked example

Network part

  1. Address 192.168.1.37 with subnet mask 255.255.255.0.
  2. ANDing each part with the mask keeps the first three numbers: network 192.168.1.0.
  3. The host part is 37.
Check yourself

How many bits are in an IPv4 address?

  • 128

  • 32

  • 8

  • 64

Show the answer

32

Four bytes.

4DNS and URLs

A URL (uniform resource locator) is a web address, such as https://www.example.org/news/index.html:

  • https is the protocol;
  • www.example.org is the domain name;
  • /news/index.html is the path to the file.

People remember names, but computers need IP addresses. The domain name system (DNS) translates names into IP addresses:

  1. The browser asks a DNS resolver for the IP address of www.example.org.
  2. If it is not stored (cached), the resolver asks a root server, then the .org server, then the server for example.org.
  3. The IP address is returned and cached.
  4. The browser connects to that IP address.

DNS is a hierarchy of servers spread across the world, so no single server has to hold every address.

Check yourself

What does DNS do?

  • Encrypts web pages before they are sent

  • Assigns MAC addresses to network cards

  • Translates domain names into IP addresses

  • Splits data into packets for sending

Show the answer

Translates domain names into IP addresses

Like a phone book.

5Common protocols and ports

A port number identifies which application or service the data is for, so one computer can run several services at once. A socket is an IP address plus a port, such as 192.168.1.37:443.

ProtocolUsePort
HTTPweb pages80
HTTPSsecure web pages (encrypted)443
FTPtransferring files21
SSHsecure remote login22
SMTPsending email25
POP3downloading email (removes it from the server)110
IMAPemail that stays on the server, synced across devices143
DNSlooking up domain names53

TCP guarantees delivery and order (used for web pages, email and files). UDP is faster but does not guarantee delivery (used for live video, games and DNS, where speed matters more than a lost packet).

Check yourself

Which protocol keeps email on the server so it can be read on several devices?

  • SMTP

  • POP3

  • FTP

  • IMAP

Show the answer

IMAP

Synced.

6Web technologies and the internet's structure

  • The internet is the global network of networks: the physical connections and routers.
  • The World Wide Web is one service that runs on the internet: web pages linked by hyperlinks, sent using HTTP.
  • Internet service providers (ISPs) connect homes and businesses to the internet.
  • A content delivery network (CDN) keeps copies of popular content on servers near users, to cut latency.
  • Cloud computing provides storage and processing as a service over the internet.
Cloud advantagesCloud disadvantages
access from anywhereneeds a reliable internet connection
no need to buy and maintain serversongoing subscription costs
easy to scale up or downdata is held by another company, raising security and legal questions
Check yourself

What is the difference between the internet and the World Wide Web?

  • They are the same thing, as both describe the network of linked computers

  • The internet is the network itself; the web is a service of linked pages that runs on it

  • The web is older than the internet and was later moved onto it

  • The internet only carries email, while the web carries everything else

Show the answer

The internet is the network itself; the web is a service of linked pages that runs on it

Network vs service.

Now test yourself

This lesson has a 8-question quiz and 5 exam-style questions with mark schemes in Impera. Free, with your progress saved.

Practise in Impera