📑 Contents

Chapter 14.1: Protocols

TCP/IP, HTTP, FTP, Email Protocols & BitTorrent

9618 Computer Science

📚 Learning Objectives
📋 Prior Knowledge Required
🌟 Did You Know?

A protocol is a set of rules that define how computers communicate over a network. Without protocols, devices would not know how to structure or interpret data, leading to lost, corrupted, or misrouted information. Protocols ensure reliable data transfer, consistent formatting, error checking, and security during transmission!

1. The Need for Protocols

When communicating over networks, it is essential that some form of protocol is used by the sender and receiver of the data. Both parties need to agree on the protocol being used to ensure successful communication takes place.

📖 What is a Protocol?

A protocol is a set of rules governing communication across a network. The rules are agreed by both sender and recipient.

⚠️ Without Protocols
📝 Example: Parity Checking Protocol

With parity checking as a way of determining whether data was transmitted correctly, it was essential to agree on the protocol: even or odd parity. Without agreeing this protocol, it would be impossible to use parity checking effectively.

Why Protocols Are Essential ❌ Without Protocol • Data corruption • Misinterpretation • Lost packets • No error detection Apply Protocol ✓ With Protocol • Reliable transfer • Correct formatting • Error detection • Secure transmission Common Protocols TCP, IP HTTP, HTTPS FTP, SMTP POP, IMAP

1.1 Protocol Stacks

A protocol stack is a way of organising network protocols into layers, where each layer is responsible for a specific function.

📖 Benefits of Layered Protocol Stacks
💡 Exam Tip

Remember: The TCP/IP protocol stack is the most important example. It uses four layers: Application, Transport, Internet, and Link. Using layers breaks the process down into manageable self-contained modules (decomposition), making it easier to develop and maintain.

2. TCP/IP Protocol Stack

TCP/IP (Transmission Control Protocol/Internet Protocol) is a suite of communication protocols used to interconnect network devices on the internet. It was developed by DARPA (Defense Advanced Research Projects Agency).

📖 The Four-Layer Structure

When sending data across the internet (network), the layers are used in the order layer 4 to layer 1; when receiving data, the layers are used in the order layer 1 to layer 4.

Sending 4. APPLICATION HTTP, FTP, SMTP, DNS 3. TRANSPORT TCP, UDP 2. INTERNET IP, ARP, ICMP 1. LINK Ethernet, WiFi INTERNET Receiving 4. APPLICATION Web browser, Email client 3. TRANSPORT Reassembly, Error check 2. INTERNET Routing, IP addressing 1. LINK Physical transmission Data → Segment → Datagram → Frame Frame → Datagram → Segment → Data (Encapsulation on send, Decapsulation on receive)
⚠️ Important Terminology

Packets are known by different names at different layers:

Different names are used as each layer adds its own header to the packet.

3. Application Layer

The application layer is where the communication process begins. It interacts directly with software applications such as web browsers and email clients. This layer prepares data for transmission by converting it into a format that can be sent and received over the network (encapsulation).

Protocol Full Name Port Function
HTTP Hypertext Transfer Protocol 80 Transfer of web pages
HTTPS HTTP Secure 443 Encrypted web transfer
FTP File Transfer Protocol 20, 21 File transfers
SMTP Simple Mail Transfer Protocol 25, 587 Sending emails
POP3 Post Office Protocol v3 110 Receiving emails
IMAP Internet Message Access Protocol 143 Receiving emails (synced)
DNS Domain Name System 53 Domain to IP translation
DHCP Dynamic Host Configuration Protocol 67, 68 Assigns IP addresses

3.1 HTTP & HTTPS

HTTP (Hypertext Transfer Protocol) is probably the most important application layer protocol. It underpins the World Wide Web and is used when fetching HTML documents from web servers.

📝 How HTTP Works
  1. User keys the URL into their browser
  2. HTTP transmits the request from application layer to transport layer (TCP)
  3. TCP creates data packets and sends them via port 80
  4. DNS server looks up the IP address using the domain name
  5. Server TCP sends back an acknowledgement
  6. Web server sends the web page back in HTML format
  7. Browser interprets the page and displays it
💡 HTTPS vs HTTP

HTTPS works the same way as HTTP but with an added layer of security. All data sent and received using HTTPS is encrypted. It is used to protect sensitive information such as passwords, financial information, and personal data. Uses port 443.

4. File Transfer Protocol (FTP)

FTP (File Transfer Protocol) is a network protocol used for transferring files from one computer/device to another via the internet or other networks. It is similar to HTTP and SMTP, but FTP's only task is the application protocol for file transfer over a network.

📖 Key Features of FTP
📝 FTP Session Process
  1. User types in the ftp host_name of remote system
  2. Enters user ID and password for authentication
  3. Connection established with FTP server
  4. User can now use FTP commands to carry out actions
FTP Command Function
delete Delete a file on the remote server
close Close the FTP connection
rename Rename a file on the remote server
cd Change directory on remote machine
lcd Change directory on local machine
get Download a file from server
put Upload a file to server
🌟 Anonymous FTP

Anonymous FTP allows a user to access files without the need to identify who they are to the FTP server. For example, '331 Anonymous access allowed' would be a message received to confirm anonymous access.

FTP Client • FileZilla • WinSCP • Web browser Upload (put) Download (get) FTP Server Port 21: Control Port 20: Data Files stored here Authentication Username + Password or Anonymous access

5. Email Protocols

A family of protocols handle sending and receiving of email across the internet (WAN). These include SMTP for sending and POP3 or IMAP for receiving emails.

5.1 SMTP (Simple Mail Transfer Protocol)

SMTP is a text-based (and connection-based) protocol used when sending emails. It is sometimes referred to as a push protocol because the client opens a connection to the server and keeps the connection active all the time, then uploads a new email to the server.

📖 Push Protocol Characteristics
⚠️ SMTP and Binary Files

Since SMTP is text-based only, it doesn't handle binary files (files containing media/images as well as text). If an email contains attachments made up of images, video, or music, it is necessary to use the MIME (Multi-purpose Internet Mail Extension) protocol instead.

📝 MIME Protocol

A MIME header is used at the beginning of the transmission. Clients use this header to select which media player is needed when the attachment is opened. MIME allows email attachments containing media files as well as text to be sent.

5.2 Email Protocol Overview

Sender Email Client (Outlook, etc.) Sender's Email Server SMTP/MIME receives email INTERNET Recipient's Email Server POP3/IMAP stores email Recipient Email Client downloads email SMTP SMTP POP3/ IMAP Protocol Summary SMTP = Push (Send) POP3/IMAP = Pull (Receive)

6. POP3 vs IMAP - Receiving Emails

POP3 (Post Office Protocol v3) and IMAP (Internet Message Access Protocol) are protocols used when receiving emails from the email server. These are known as pull protocols.

📖 Pull Protocol Characteristics

6.1 POP3 (Post Office Protocol)

📝 POP3 Procedure
  1. Connect to the email server and authenticate
  2. Retrieve outstanding emails from the server
  3. Delete retrieved emails from the server (optional but common)
  4. Disconnect from the server

6.2 IMAP (Internet Message Access Protocol)

IMAP is similar to POP3 but offers more functionality:

Aspect POP3 IMAP
Synchronisation No sync - emails deleted from server after download Full sync - server and client stay synchronised
Storage Emails stored locally on device Emails stored on server
Multi-device Can only access from download device Can access from any device with internet
Server Space Frees up server storage space Server storage can limit retained emails
Offline Access Better for offline access (emails stored locally) Requires internet to view emails
Changes Changes not reflected across devices Changes on one device sync to all devices
💡 Exam Tip - Key Difference

The main difference between POP3 and IMAP is synchronisation:

7. BitTorrent Protocol

BitTorrent is a peer-to-peer (P2P) file-sharing protocol used to distribute large amounts of data efficiently across the internet. It is a communication protocol for peer-to-peer file sharing which enables users to distribute data and electronic files over the Internet in a decentralized manner.

📖 How BitTorrent Works

Instead of downloading a file from a single central server, BitTorrent allows users to download pieces of the file from multiple users (peers) who already have parts of it.

7.1 Key Terminology

Term Definition
Torrent A small file containing metadata about the file to be shared (e.g., MyVideoFile.torrent)
Tracker Central server that stores details of all computers in the swarm (IP addresses)
Swarm A group of connected peers (clients) that share a torrent/tracker
Seed A peer that has downloaded a file (or pieces) and made it available to other peers
Leech A peer with negative impact - downloading more than uploading (share ratio < 1)
Lurker A peer that downloads files but does not make available any new content
Pieces The actual file broken up into equal segments for sharing
Metadata A set of data that describes and gives information about other data
Share Ratio = Amount uploaded ÷ Amount downloaded
Ratio > 1 = positive impact (good peer) | Ratio < 1 = negative impact (leech)

8. BitTorrent Process

📝 How BitTorrent File Sharing Works
  1. Peer creates a torrent file containing metadata about the file to be shared
  2. Actual file is broken up into equal segments called pieces
  3. Other peers obtain the torrent and connect to the appropriate tracker
  4. Each peer receives pieces and becomes a source for those pieces
  5. Peers connect to multiple seeds and download small portions from each
  6. Higher download speeds achieved by using multiple sources
  7. Complete file is checked using checksum to verify integrity
  8. Once fully downloaded, peer becomes a seed and can share with others
TRACKER Stores IP addresses SEED 1 100% file Sharing SEED 2 100% file Sharing SEED 3 100% file Sharing SEED 4 100% file Sharing LEECH Ratio < 1 LEECH Ratio < 1 NEW PEERS Just joined SWARM Legend Seed (has 100%) Leech (downloading) New peer (just started)
❌ Common Mistakes

9. Transport Layer

The transport layer regulates the network connections. This is where data is broken up into packets which are then sent to the internet/network layer (IP protocol). It ensures that packets arrive in sequence, without errors, by swapping acknowledgements and retransmitting packets if they become lost or corrupted.

9.1 TCP (Transmission Control Protocol)

TCP is responsible for the safe delivery of a message by creating sufficient packets for transmission. It is also known as a host-to-host transmission protocol because it establishes an end-to-end connection between two host computers using handshakes.

📖 TCP Characteristics
📝 TCP Host-to-Host Communication (Three-Way Handshake)
  1. Host 'X' sends Host 'Y' a segment with synchronisation sequence bits so segments will be received in correct order
  2. Host 'Y' responds with its own segment containing an acknowledgement plus its own synchronisation sequence bits
  3. Host 'X' sends acknowledgement that segment from 'Y' was received
  4. Transmission of data between 'X' and 'Y' can now take place

9.2 TCP vs UDP

Feature TCP UDP
Connection Connection-oriented (handshake) Connectionless
Reliability Reliable (acknowledgements, retransmission) Unreliable (no guarantees)
Speed Slower (due to error checking) Faster (no error checking overhead)
Ordering Packets arrive in order Packets may arrive out of order
Use Case Email, web pages, file transfer Streaming, gaming, VoIP
💡 Exam Tip

A host is a computer or device that can communicate with another computer/device on a network. Hosts can include clients and servers that send/receive data, provide services or apps.

10. Internet Layer

The internet layer identifies the intended network and host. The common protocol is IP (Internet Protocol). This layer is responsible for logical transmission of data packets over the internet.

📖 IP Functions

10.1 Internet Layer Protocols

Protocol Full Name Function
IP Internet Protocol Connectionless, unreliable protocol providing best-effort delivery; transports datagrams over different routes
ARP Address Resolution Protocol Maps logical address (IP) to physical address (MAC)
RARP Reverse ARP Finds IP address when physical (MAC) address is known
ICMP Internet Control Message Protocol Monitors queries and sends error messages
IGMP Internet Group Message Protocol Allows transmission of a message to a group simultaneously
🌟 Important Note

At the internet layer, packets are called datagrams. The IP packet (datagram) is sent to the data-link layer where it is assembled into frames for transmission.

11. Link (Network) Layer

The link layer (also called network interface layer) is the lowest layer of the TCP/IP model. It is concerned with the physical transmission of data. It can be considered as the combination of physical layer and data link layer of the OSI model.

📖 Link Layer Functions

11.1 Ethernet Protocol

Ethernet is a system that connects a number of computers or devices together to form a LAN. It uses protocols to control the movement of frames between computers and to avoid simultaneous transmission by two or more devices.

📝 Ethernet Frame Structure

A typical Ethernet frame contains:

Ethernet Frame Structure Preamble (8 bytes) Destination (6 bytes) Source (6 bytes) Type/Length (2 bytes) Data (Message) (46-1500 bytes) FCS (4 bytes) FCS = Frame Check Sequence (checksum for data integrity)

11.2 CSMA/CD

CSMA/CD (Carrier Sense Multiple Access with Collision Detection) is a network protocol used in Ethernet networks. It senses whether the shared channel is busy and defers transmission until the channel is free. If a collision is detected, the station stops transmitting, sends a jam signal, and waits for a random time before retransmission.

12. Exam-Style Questions

1. Explain why protocols are essential for network communication. Describe what could happen if no protocols were used. [4 marks]

Answer:

  • Protocols are sets of rules that define how computers communicate over a network
  • They ensure data is sent, received, and understood correctly by all devices
  • Without protocols, devices would not know how to structure or interpret data
  • Data could be lost, corrupted, or misrouted
  • Communication between different hardware and software systems would break down
  • No error checking and correction would be possible

Additional points for deeper understanding:

  • Protocols guarantee reliable data transfer and consistent formatting
  • They enable addressing and security during transmission
2. Describe the four layers of the TCP/IP protocol stack and explain the function of each layer. [8 marks]

Answer:

  • Application Layer (Layer 4): Where communication begins; interacts with software applications (browsers, email clients); prepares data for transmission (encapsulation); protocols include HTTP, FTP, SMTP, DNS
  • Transport Layer (Layer 3): Regulates network connections; breaks data into packets (segments); assigns port numbers; ensures packets arrive in sequence without errors; uses TCP or UDP
  • Internet Layer (Layer 2): Identifies intended network and host; adds IP addresses to packet headers; routes packets across the network; uses IP, ARP, ICMP
  • Link Layer (Layer 1): Prepares packets for physical transmission; translates digital packets into electrical, optical, or wireless signals; encapsulates into frames; uses Ethernet, WiFi

Additional points for deeper understanding:

  • When sending: data flows from Layer 4 down to Layer 1
  • When receiving: data flows from Layer 1 up to Layer 4
  • Each layer adds its own header to the packet
3. Compare HTTP and HTTPS. Why is HTTPS preferred for secure transactions? [4 marks]

Answer:

  • HTTP (Hypertext Transfer Protocol) transfers web pages between client and server using port 80
  • HTTPS works the same way but adds an encryption layer using SSL/TLS
  • HTTPS uses port 443 instead of port 80
  • HTTPS is preferred for secure transactions because all data is encrypted
  • Encryption protects sensitive information like passwords, financial data, and personal information

Additional points for deeper understanding:

  • HTTPS prevents man-in-the-middle attacks
  • HTTPS provides authentication of the website server
4. Explain the difference between a push protocol and a pull protocol. Give an example of each. [4 marks]

Answer:

  • Push protocol: Client opens connection to server and keeps it active; uploads data to server
  • Example: SMTP for sending emails - client uploads new email to server
  • Pull protocol: Client periodically connects to server; checks for and downloads data; connection closes after download
  • Example: POP3 or IMAP for receiving emails - client connects, downloads emails, disconnects

Additional points for deeper understanding:

  • Push protocols maintain active connection throughout the transfer
  • Pull protocols are more efficient for periodic checking/updates
5. Compare POP3 and IMAP protocols for receiving emails. When would you recommend using each? [6 marks]

Answer:

  • POP3: Downloads emails and typically deletes from server; emails stored locally; no synchronisation between devices
  • IMAP: Downloads copy of emails; original remains on server; full synchronisation across all devices
  • Recommend POP3 when: user wants offline access, has limited server storage, only uses one device
  • Recommend IMAP when: user accesses email from multiple devices, needs synchronisation, works in an organisation
  • POP3 frees up server storage space; IMAP allows access from any device with internet
  • Changes made on one device are reflected on all devices with IMAP, but not with POP3

12. Exam-Style Questions (Continued)

6. Describe the role of a tracker in the BitTorrent protocol. What information does it store? [4 marks]

Answer:

  • A tracker is a central server that stores details about all computers in the swarm
  • It stores the IP addresses of all peers downloading or uploading the file
  • It stores metadata about the torrent (file information, piece sizes)
  • It helps peers locate each other to exchange pieces of the file
  • It stores which parts of the file each peer owns

Additional points for deeper understanding:

  • The tracker does NOT store the actual file being shared
  • Multiple trackers can be used for redundancy
7. Explain the terms 'seed', 'leech', and 'swarm' in the context of BitTorrent. [6 marks]

Answer:

  • Seed: A peer that has downloaded a complete file (or pieces) and has made it available to other peers in the swarm
  • Leech: A peer with negative impact on the swarm - downloads more data than it uploads (share ratio < 1)
  • Swarm: A group of connected peers (clients) that share a particular torrent/tracker
  • The more seeds in a swarm, the faster the file downloading process between peers
  • Logging off after downloading without seeding is frowned upon by the community (becoming a leech)
  • Availability refers to the number of complete copies distributed amongst a swarm
8. Describe how TCP ensures reliable data transmission. Include the concept of handshakes in your answer. [5 marks]

Answer:

  • TCP is connection-oriented - it establishes an end-to-end connection using handshakes
  • Three-way handshake: (1) Host X sends synchronisation bits to Host Y, (2) Host Y responds with acknowledgement and its own sync bits, (3) Host X acknowledges
  • TCP uses Positive Acknowledgement with Retransmission (PAR) - automatically re-sends packets if no positive acknowledgement received
  • TCP ensures packets arrive in sequence using synchronisation sequence bits
  • TCP provides error checking and flow control

Additional points for deeper understanding:

  • TCP breaks data into segments and assigns port numbers
  • TCP can request retransmission of corrupted or lost packets
9. Explain the difference between TCP and UDP. Give an example of when each would be used. [6 marks]

Answer:

  • TCP: Connection-oriented, requires handshake, reliable with acknowledgements and retransmission, ensures packets arrive in order, slower due to overhead
  • UDP: Connectionless, no handshake required, unreliable with no guarantees, packets may arrive out of order, faster due to no error checking overhead
  • TCP used for: Email (SMTP), web pages (HTTP), file transfer (FTP) - where reliability is critical
  • UDP used for: Video streaming, online gaming, VoIP - where speed is more important than perfect delivery
  • TCP is better when data integrity is essential; UDP is better for real-time applications
10. Explain the role of MIME in email transmission. Why is it necessary? [4 marks]

Answer:

  • MIME (Multi-purpose Internet Mail Extension) is a protocol that allows email attachments containing media files
  • SMTP is text-based only and cannot handle binary files (files with images, video, music)
  • MIME adds a header at the beginning of transmission to indicate the type of content
  • Clients use the MIME header to select the appropriate media player for attachments
  • Without MIME, emails could only contain plain text

Additional points for deeper understanding:

  • MIME supports various content types: images, audio, video, application files
  • MIME enables international character sets beyond ASCII
11. Describe the purpose and function of the Ethernet frame check sequence (FCS). [3 marks]

Answer:

  • The FCS (Frame Check Sequence) is a 4-byte field in an Ethernet frame
  • It contains a checksum value calculated from the frame's data
  • Used to verify data integrity following transmission of the frame
  • Receiver recalculates the checksum and compares with FCS to detect errors
  • If checksums don't match, the frame is corrupted and can be rejected
12. Explain why packets are given different names at different layers of the TCP/IP stack. [4 marks]

Answer:

  • Each layer adds its own header to the packet during encapsulation
  • Segments at transport layer - include TCP/UDP header with port numbers
  • Datagrams at internet layer - include IP header with source/destination IP addresses
  • Frames at link layer - include Ethernet header with MAC addresses
  • Different names reflect the additional information added at each layer
  • This helps in understanding what processing has been applied to the data

13. Glossary

📖 Key Terms

Protocol → A set of rules governing communication across a network; agreed by both sender and recipient

TCP/IP → Transmission Control Protocol/Internet Protocol; suite of protocols for internet communication

HTTP → Hypertext Transfer Protocol; transfers web pages between client and server

HTTPS → HTTP Secure; encrypted version of HTTP using SSL/TLS

FTP → File Transfer Protocol; transfers files between computers

SMTP → Simple Mail Transfer Protocol; sends emails (push protocol)

POP3 → Post Office Protocol version 3; receives emails (pull protocol, no sync)

IMAP → Internet Message Access Protocol; receives emails (pull protocol, synced)

DNS → Domain Name System; translates domain names to IP addresses

DHCP → Dynamic Host Configuration Protocol; assigns IP addresses automatically

MIME → Multi-purpose Internet Mail Extension; allows media attachments in emails

📖 BitTorrent Terms

Torrent → Small file containing metadata about file to be shared

Tracker → Central server storing IP addresses of peers in a swarm

Swarm → Group of connected peers sharing a torrent

Seed → Peer with complete file sharing with others

Leech → Peer downloading more than uploading (ratio < 1)

Pieces → Equal segments a file is broken into for sharing

Metadata → Data that describes and gives information about other data

📖 Layer Terms

Packet → Small group of bits a message is split into for transmission

Segment → Packet at transport layer (TCP/UDP header added)

Datagram → Packet at internet layer (IP header added)

Frame → Packet at link layer (Ethernet header added)

Host → Computer or device that can communicate on a network

Router → Device that transmits packets and decides where to send them

📖 Protocol Types

Push Protocol → Client opens connection, keeps it active, uploads data (e.g., SMTP)

Pull Protocol → Client connects, downloads, disconnects (e.g., POP3, IMAP)

Connection-oriented → Requires handshake before data transfer (TCP)

Connectionless → No handshake required (UDP)

14. Exam Success Tips (Part 1)

💡 Protocol Layers - Remember the Order
💡 Packet Names at Each Layer
💡 Push vs Pull Protocols
💡 POP3 vs IMAP
💡 BitTorrent Key Terms

14. Exam Success Tips (Part 2)

🧠 Memory Tricks
❌ Common Mistakes to Avoid
💡 Port Numbers to Remember
Protocol Port
HTTP 80
HTTPS 443
FTP (Data) 20
FTP (Control) 21
SMTP 25, 587
DNS 53
💡 Answer Structure Tips

15. Key Takeaways

📌 Protocol Fundamentals
📌 Application Layer
📌 BitTorrent
📌 Transport & Internet Layers
📌 Link Layer
🌟 Final Reminder

Remember: The TCP/IP stack enables communication between different devices and operating systems using standardised rules. Each layer adds its own header - packets become segments (transport), datagrams (internet), then frames (link). Understanding the flow from application to physical transmission is key to mastering network protocols!