Networks and Web Technologies
The TCP/IP stack, packet switching, DNS, client server and peer to peer, HTML, CSS and JavaScript, search indexing and PageRank.
Networks and protocols
The TCP/IP stack
| Layer | Responsibility | Protocols |
|---|---|---|
| Application | Provides services to user software and formats data | HTTP, HTTPS, FTP, SMTP, IMAP, POP3, DNS |
| Transport | Splits data into segments, adds port numbers, ensures reliable delivery | TCP, UDP |
| Network or Internet | Adds source and destination IP addresses, routes packets across networks | IP, ICMP |
| Link or Data link | Handles physical transmission on the local medium, adds MAC addresses | Ethernet, Wi-Fi |
Data passes down the stack at the sender, gaining a header at each layer, and up the stack at the receiver, with each header removed by the corresponding layer. This is encapsulation.
Why layering: each layer can be developed, replaced or upgraded independently; hardware and software from different manufacturers interoperate provided they follow the rules of their layer; faults can be isolated to a single layer.
TCP against UDP. TCP is connection oriented, guaranteeing delivery, ordering and error checking, at the cost of overhead. UDP is connectionless with no guarantee of delivery or order, which makes it faster and therefore preferred for live video, voice and gaming, where a late packet is worse than a missing one.
Packet switching and circuit switching
Packet switching divides data into packets, each carrying source and destination addresses and a sequence number, routed independently and reassembled at the destination.
- Efficient use of the network, since capacity is shared
- Resilient, because packets route around failures
- Variable delay, and packets may arrive out of order
Circuit switching establishes a dedicated path for the duration of the communication.
- Consistent quality and guaranteed bandwidth
- Wasteful, since the circuit is reserved even when nothing is being sent
DNS
The Domain Name System resolves human readable names to IP addresses through a hierarchy of servers: root servers, then top level domain servers such as .uk, then authoritative name servers for the specific domain. Results are cached at every level, which is why a repeated lookup is almost instant.
Network security and hardware
- Firewalls filter traffic against rules. Packet filtering examines headers, while stateful inspection tracks whole connections and is more effective.
- A proxy server sits between clients and the internet, hiding client addresses, caching frequently requested content, and filtering requests.
- Network address translation allows many devices to share one public IP address.
- Client server centralises resources, backup and control but creates a single point of failure and a potential bottleneck. Peer to peer distributes load with no single point of failure but has no central management or backup, and performance depends on which peers are online.
- Your message starts at the top, in the application.
- Transport splits it into segments and adds a port number.
- Internet wraps each segment in a packet and adds IP addresses.
- Link turns the packet into a frame with MAC addresses, and it goes out.
- At the other end the same four layers run in reverse, unwrapping it.
Web technologies
HTML, CSS and JavaScript
HTML defines structure and content. CSS defines presentation. JavaScript provides behaviour and runs in the browser.
<div id="quiz" class="panel">
<h2>Question 1</h2>
<button onclick="check()">Submit</button>
</div>.panel { border: 1px solid #ccc; padding: 1rem; }
#quiz { background: #f4f4f4; }function check() {
const panel = document.getElementById("quiz");
panel.classList.add("answered");
}Client side and server side processing
| Client side | Server side | |
|---|---|---|
| Runs on | The user's browser | The web server |
| Speed | Immediate, no round trip needed | Requires a request and response |
| Server load | Reduced | Increased |
| Security | Can be viewed and altered by the user, so never trust it alone | Code and data are hidden from the user |
| Typical use | Form validation for usability, interface effects, animation | Authentication, database access, payment, authoritative validation |
Client side validation improves the experience by giving immediate feedback. Server side validation provides the security, because a user can disable JavaScript or send a crafted request directly. Validate on both, and trust only the server.
Search engine indexing
A web crawler follows links from page to page, retrieving content. Each page is analysed and added to an index mapping words to the pages containing them, along with position and prominence information. When a query arrives, the index is consulted rather than the web itself, which is what makes results appear instantly rather than after a search of billions of pages.
robots.txt lets a site request that crawlers avoid particular paths.
PageRank
PageRank orders results by importance, estimated from the link structure of the web.
- A link to a page counts as a vote for it
- Votes from pages that are themselves important count for more
- A page's outgoing votes are divided among the pages it links to, so a page linking to a thousand others confers little on each
- A damping factor, typically 0.85, models a user eventually stopping following links, and keeps the calculation convergent
PR(A) = (1 - d) + d ( PR(T1)/C(T1) + ... + PR(Tn)/C(Tn) )
where d is the damping factor, T1 to Tn are pages linking to A, and C(T) is the number of outgoing links from T.
The calculation is iterative: every page starts with an equal rank and the formula is applied repeatedly until the values converge.
- You type an address. The browser needs the IP address behind the name.
- A DNS server looks up the name and returns the IP address.
- The browser sends an HTTP request to that address.
- The server sends back HTML, CSS, images and scripts.
- The browser renders them into the page you see.
- Client side code runs in the browser: HTML for structure, CSS for style, JavaScript for behaviour. It gives instant feedback.
- Server side code runs on the server and uses the database. The user cannot see it, so it does the secure checks.
- The user can see and change client side code, so never trust it for security.
Key terms you must be able to define
- TCP/IP stack
- A four layer model organising network protocols into application, transport, network and link layers.
- Encapsulation
- Adding a header at each layer as data passes down the stack, removed at the corresponding layer on receipt.
- TCP
- A connection oriented transport protocol guaranteeing delivery, ordering and error checking.
- UDP
- A connectionless transport protocol with no delivery guarantee, used where speed matters more than reliability.
- Packet switching
- Dividing data into independently routed packets reassembled at the destination.
- Circuit switching
- Establishing a dedicated path for the duration of a communication.
- DNS
- The hierarchical system resolving domain names into IP addresses.
- Proxy server
- A server sitting between clients and the internet, hiding addresses, caching and filtering.
- Client side processing
- Code executed in the user's browser, giving immediate response but no security.
- Server side processing
- Code executed on the web server, hidden from the user and therefore trustworthy.
- Web crawler
- A program following links to retrieve pages for indexing by a search engine.
- PageRank
- An algorithm ranking pages by importance derived from the link structure of the web.
- Damping factor
- A constant in PageRank modelling the probability that a user stops following links.
Flashcards
Say the definition out loud before you flip the card. Retrieving it from memory is what builds recall, reading it again is not.
Reach the top grade on this topic
- Name all four TCP/IP layers with their protocols and describe encapsulation in both directions
- Compare TCP and UDP and give a scenario where UDP is genuinely preferable
- Explain why client side validation is never sufficient on its own
- Explain PageRank as weighted votes divided by outgoing link count, not simply counting links
- Explain the role of the damping factor rather than treating it as an arbitrary constant
Mistakes that cost marks here
- Placing protocols at the wrong layer. HTTP is application, TCP is transport, IP is network.
- Saying UDP is simply worse than TCP. For live video, a late packet is more damaging than a missing one.
- Saying client side validation makes a form secure. It can be bypassed entirely.
- Describing PageRank as counting inbound links. Votes are weighted and divided among outgoing links.
- Confusing packet switching with circuit switching in a comparison question.
PageRank works by treating a link as a vote, but weights each vote by the importance of the page casting it. The mathematics is an eigenvector calculation on a matrix with billions of rows, and it made Google.
Knowledge check
Exam-style questions
Five written questions in the style of the real paper. Write a full answer, then let the marker check it against the mark scheme.
- LThe application layer provides services to user software and formats data
- LThe transport layer splits data into segments and ensures reliable delivery
- LThe network layer adds IP addresses and routes packets between networks
- LThe link layer handles physical transmission and uses MAC addresses
The application layer is where the protocols used directly by software operate, such as HTTP for web pages and SMTP for sending mail, and it is responsible for formatting the data appropriately for the service being used. The transport layer takes that data and divides it into segments, adding port numbers so the receiving machine knows which application the data belongs to, and where TCP is used it also numbers the segments and manages acknowledgements and retransmission to guarantee complete, correctly ordered delivery. The network layer, sometimes called the internet layer, attaches the source and destination IP addresses and is responsible for routing each packet across the intervening networks towards its destination. The link layer handles the actual transmission over the physical medium, adding MAC addresses so that frames reach the correct device on the local network, and it is where Ethernet and Wi-Fi operate.
- LUDP is connectionless and does not guarantee delivery or ordering
- LThis reduces overhead so data arrives with lower latency
- LIn a live call a retransmitted packet would arrive too late to be useful
- LA small amount of lost data causes a brief glitch, which is preferable to delay
UDP is connectionless: it sends datagrams without establishing a connection, without acknowledgements and without retransmitting anything that is lost, so it carries far less overhead than TCP and delivers data with noticeably lower latency. That matters enormously in a live call, where the total delay between speaking and being heard determines whether a conversation is usable at all. The decisive point is what would happen if TCP were used instead. If a packet carrying a fiftieth of a second of audio were lost, TCP would detect the gap and retransmit it, but by the time the replacement arrived that moment in the conversation would already have passed, so the retransmitted data is worthless while the stall waiting for it is very noticeable. With UDP the missing fragment simply produces a momentary glitch that the human ear largely ignores, and the call continues smoothly. In short, for live media a small amount of loss is far preferable to delay, which is precisely the trade UDP makes.
- LClient side code runs in the user's browser
- LServer side code runs on the web server
- LClient side gives immediate feedback without a round trip to the server
- LClient side code can be viewed, disabled or altered by the user
- LServer side validation is authoritative because the user cannot bypass it
Client side processing is code, usually JavaScript, that is downloaded and executed by the user's own browser, whereas server side processing runs on the web server and only the results are sent to the client. The advantage of client side processing is responsiveness: a form field can be checked the moment the user leaves it, with no request to the server and no waiting, which makes the interface feel immediate and reduces load on the server. The critical weakness is that anything running on the user's machine is entirely under their control. They can read the source, disable JavaScript altogether, modify the code with browser developer tools, or bypass the page completely and send a crafted request directly to the server. Client side validation therefore provides usability but no security whatsoever. Server side validation is authoritative because the user cannot alter or bypass it, and it is the only check that can be trusted to protect the database from invalid or malicious data. Both are used together: client side for a good experience, server side because it is the only one that actually enforces anything.
- LA link from one page to another is treated as a vote for the target page
- LVotes from pages that are themselves important carry more weight
- LA page's vote is divided among all the pages it links to
- LA damping factor models the probability that a user stops following links
- LThe calculation is iterative, repeated until the values converge
PageRank estimates the importance of a page from the structure of links pointing at it, treating each incoming link as a vote of confidence. Crucially the votes are not counted equally: a link from a page that is itself highly ranked contributes far more than a link from an obscure one, so the rank of a page depends recursively on the ranks of the pages linking to it. Each page's voting power is also divided among all the pages it links out to, so a page with a thousand outgoing links passes only a thousandth of its rank to each, which prevents importance being manufactured simply by linking to everything. A damping factor, conventionally 0.85, is applied to model the probability that a person following links eventually stops and starts somewhere new, and it also guarantees that the mathematics converges rather than concentrating all rank in a small group of pages. Because each page's rank depends on others which are themselves being calculated, the algorithm is iterative: every page begins with an equal rank, the formula is applied to every page, and this repeats until the values stop changing significantly.
- LClient server has dedicated servers providing resources to clients
- LPeer to peer has all machines acting as both client and server
- LClient server allows central backup, security and account management
- LClient server has a single point of failure and can become a bottleneck
- LPeer to peer is cheaper with no dedicated server and distributes load
- LPeer to peer has no central backup or management and depends on which peers are online
In a client server network, dedicated server machines provide resources and services which client machines request, so files, authentication and applications are centralised. In a peer to peer network every machine is an equal that acts as both client and server, sharing its own resources directly with the others. The client server model's strength is control: data can be backed up centrally in one place, user accounts and permissions are administered from a single point, and software updates and security policies are applied consistently across the whole network, which is essential once an organisation grows beyond a handful of machines. Its weaknesses are cost and dependency, since server hardware and specialist staff are expensive, the server represents a single point of failure whose loss affects every user, and it can become a bottleneck if demand exceeds what it can serve. Peer to peer inverts this. It is cheap to set up because there is no server to buy, load is naturally distributed across the participants so it scales well as more peers join, and there is no single point of failure. In exchange it offers no central backup, so data protection depends on each user individually, no central management of security or updates, and availability depends entirely on which peers happen to be switched on, so a file may simply be unreachable. In practice client server suits organisations needing control and reliability, while peer to peer suits small informal networks and distributed content sharing.