← IB Computer Science

A2.1 · Book pp. 112–126

Network fundamentals

Your level

You use networks all day and notice them only when they fail. This section looks at what they are built from and the rules that keep them working.

What you need to know

PointTopicLevel
A2.1.1Purpose and characteristics of networksSL + HL
A2.1.2Modern digital infrastructuresSL + HL
A2.1.3The function of network devicesSL + HL
A2.1.4Network protocols for transport and applicationSL + HL
A2.1.5The function of the TCP/IP modelHL

🔬 Try this first

On your computer, run ipconfig on Windows or ifconfig on a Mac or Linux. Find your IP address and your default gateway. By the end of this section you will know what both of them do.

Next: types of network →

A2.1.1 Purpose and characteristics of networks

A computer network connects devices so that they can share resources and information, such as files, printers, apps and internet access.

NameRangeExample
PANPersonal area networkAbout 10 m around one personPhone, watch and earbuds over Bluetooth
LANLocal area networkOne home, building or campusA school’s computers and printers. Typically 100 Mbps to 10 Gbps
WLANWireless LANAs for a LANWi-Fi in a home
WANWide area networkAcross cities or continentsA company linking its branch LANs
VPNVirtual private networkAny distance, over a public networkAn encrypted tunnel for staff working from home

Latency is the delay for data to travel across a network. Bandwidth is how much data it can carry each second.

A classic WAN has its own long-distance links. Most modern WANs use the internet instead, with VPNs keeping the traffic private, which is far cheaper.

⚠️ Common mistake

Consumer VPN apps that make you appear in another country are a different use case. In exam answers, focus on secure remote access to a private network.

A2.1.2 Modern digital infrastructures

InfrastructureWhat it isBenefitLimitation
InternetGlobal network of networksNear-instant access to servicesVulnerable to hacking, phishing and denial of service
Cloud computingRented computing from data centresScales up or down, with low maintenance costNeeds reliable internet. Data sits with a third party
Distributed systemsMany connected nodes share a goalFault tolerant, with many pathsComplex, and data must stay consistent
Edge computingComputing and storage close to usersLower latency and bandwidth useMore endpoints to secure and maintain
Mobile networksWireless cell towersMobility, and covers places without cablesDead zones and varying signal strength

BitTorrent and blockchains are distributed systems. Content delivery networks spread files around the world, and streaming services place servers in major cities as a form of edge computing.

Check yourself
  1. A farm has sensors in remote fields with no cables. Which infrastructure fits? Mobile networks, if there is coverage.
  2. Why are distributed systems fault tolerant? If one node fails, the others can continue by another route.

Next: network devices →

A2.1.3 Network devices

A home “router” is really several logical devices in one box. Learn each device by the problem it solves.

Internet Modem Firewall Router Switch Wi-Fi AP
Original diagram: the logical devices inside a typical home box.
DeviceFunctionTCP/IP layer
GatewayConnects two different networks and translates between their protocolsUp to application
Hardware firewallAllows or blocks traffic using security rules on addresses and portsInternet and transport
ModemConverts between digital signals and analogue signalsNetwork interface
Network interface cardConnects one device to a network by cable or antennaNetwork interface
RouterForwards packets between networks using IP addressesInternet
SwitchForwards data inside one LAN using MAC addressesNetwork interface
Wireless access pointConnects wireless devices to a network, and can extend rangeNetwork interface

✏️ Book correction

The book places routers at the network interface layer. Routing uses IP addresses, so routers work at the internet layer, as shown above.

🔬 Lab: which device?

Next: protocols →

A2.1.4 Network protocols

A protocol is a set of rules for how data is sent and received.

TCP and UDP

IP gets data from one computer to another. TCP and UDP get it from one application to another using port numbers, a bit like flat numbers in a building.

TCPUDP
ConnectionConnection-orientedConnectionless
ReliabilityLost or corrupted data is re-sentNo guarantee
OrderSequence numbers restore the orderNo guarantee
OverheadHigher, with a 20-byte header or moreLower, with an 8-byte header
Used forWeb, email, filesLive video, voice, games
ProtocolDefault portTransportUse
HTTP80TCPWeb pages
HTTPS443TCPEncrypted web pages
SSH22TCPSecure remote login
SMTP587 (also 25)TCPSending email

🔬 Lab: send a message over a bad network

Choose a protocol.

Each packet carries one word. Out-of-order arrival and loss are simulated at random, so try it a few times.

✍️ Programming: talk over TCP

Run the server, then run the client in a second terminal.

import socket

with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:   # IPv4 + TCP
    s.bind(("0.0.0.0", 65432))
    s.listen()
    conn, addr = s.accept()              # waits for a client
    with conn:
        print("Connected by", addr)
        while True:
            data = conn.recv(1024)       # up to 1024 bytes
            if not data:
                break
            conn.sendall(data.decode().upper().encode())
import socket

with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
    s.connect(("127.0.0.1", 65432))      # 127.0.0.1 is this computer
    s.sendall("hello, server".encode())
    print(s.recv(1024).decode())

HTTP and HTTPS

HTTP is the protocol of the web. It is stateless and human-readable. A client sends a request and the server replies with a status code, such as 200 (OK) or 404 (not found).

GET /index.html HTTP/1.1
Host: www.example.com

HTTP/1.1 200 OK
Content-Type: text/html

<h1>Welcome</h1>
import requests

response = requests.get("https://www.example.com")
print(response.status_code)
print(response.text[:200])

HTTPS adds encryption, normally TLS, authentication through a server certificate, and integrity, so that changes in transit are detected. It protects against eavesdroppers and man-in-the-middle attacks.

DHCP

DHCP gives a device an IP address when it joins a network. Addresses are leased for a set time, so they can be reused.

🔬 Lab: DHCP step by step

    🔬 Lab: private or public address?

    Private ranges: 10.0.0.0 to 10.255.255.255, 172.16.0.0 to 172.31.255.255 and 192.168.0.0 to 192.168.255.255. They are not routable on the public internet, so these networks rely on network address translation.

    Next: the TCP/IP model →

    Next: review →

    HL A2.1.5 The TCP/IP model

    The TCP/IP model splits networking into four layers, each with one responsibility. It has largely replaced the older OSI model.

    LayerExamplesJobData unit
    ApplicationHTTP, HTTPS, FTP, SMTP, POP3, DNSForms the messages that programs exchangeMessage
    TransportTCP, UDPMoves data between the right applications using ports. TCP also splits, checks and re-sendsSegment or datagram
    InternetIPAddresses and routes packets across networksPacket
    Network interfaceEthernet, Wi-Fi, MAC addressingSends bits to the next device over the physical mediumFrame

    🔬 Lab: encapsulation

    ⚠️ Common mistake

    Keep a clear map: HTTP, HTTPS and DHCP are application layer. TCP and UDP are transport. Switches and MAC addresses are network interface. Routers and IP are internet.

    Next: review →

    Quick quiz

    1. A phone, a watch and earbuds linked by Bluetooth form a…
    2. What does a VPN add over the public internet?
    3. Which infrastructure handles data close to where it is produced?
    4. Which device forwards data inside a LAN using MAC addresses?
    5. Which device connects your LAN to another network and picks a path?
    6. A live video call would normally use…
    7. What does a port number identify?
    8. What does “stateless” mean for HTTP?
    9. What is the correct DHCP order?

    HL Extra questions

    1. At which TCP/IP layer does routing happen?
    2. Where does HTTPS belong?
    3. What does encapsulation mean?

    Exam-style questions

    These are written for this site in the style of Paper 1. Answer on paper first, then open the mark points.

    1. Describe one difference between a LAN and a WAN. [2]

      Mark points
      • A LAN covers a small area such as a building [1].
      • A WAN connects networks over a large area such as several cities [1].
    2. Discuss one benefit and two limitations of cloud computing for a small business. [3]

      Mark points
      • Benefit: it can scale without buying hardware, which lowers cost [1].
      • Limitation: it depends on reliable, fast internet [1].
      • Limitation: data on third-party systems raises security and privacy concerns [1].
    3. Explain why a video service caches popular films in local servers. [2]

      Mark points
      • Data has less distance to travel, so latency falls [1].
      • Less traffic reaches the main servers, which saves bandwidth [1].
    4. Outline the role of a router, a switch and a modem in a home network. [3]

      Mark points
      • The switch connects devices within the LAN [1].
      • The router forwards packets between the LAN and the internet [1].
      • The modem converts between digital signals and the form used on the line [1].
    5. Compare TCP and UDP. [4]

      Mark points
      • TCP is connection-oriented, while UDP is connectionless [1].
      • TCP guarantees ordered delivery with sequence numbers and acknowledgements [1].
      • UDP has less overhead, so it is faster [1].
      • UDP can lose or reorder data, which suits live streaming, while TCP suits file transfer [1].
    6. Describe three features HTTPS adds to HTTP. [3]

      Mark points
      • Encryption stops eavesdroppers from reading the data [1].
      • Certificates authenticate the server [1].
      • Integrity checks detect changes in transit [1].
    7. Outline how a laptop gets an IP address when it joins a network. [3]

      Mark points
      • It broadcasts a DHCP Discover message [1].
      • A server sends an Offer of an address from its pool [1].
      • The laptop Requests that address and the server Acknowledges it, giving a lease [1].

    HL Exam-style questions

    1. Describe how a web request passes down the TCP/IP model on the sending computer. [4]

      Mark points
      • Application: the browser forms an HTTP request [1].
      • Transport: TCP splits it into segments and adds ports and sequence numbers [1].
      • Internet: IP adds source and destination addresses to form packets [1].
      • Network interface: the data is framed with MAC addresses and sent as signals [1].