Study Guide Instructor view

TCP, UDP, Ports and Sockets

Teaching notes for Lesson 3.8, with controls for presenting it.

Keep this page on your own screen. Share only the lesson window. The lesson window holds no teaching notes, so sharing it cannot show them.

Presenting

  1. Open the lesson in its own window and share that window, not this one.
  2. Use Next and Previous here, or the lesson’s own, to move through the lesson. Next reveals one thing at a time: the next idea, or the answer to the question on screen, then the next step. Previous takes the last reveal back. The line below says what is on screen and what Next will show.
  3. Reveal hints and answers when the class is ready, and reset a demonstration before using it again.

The controls need JavaScript and a browser that supports BroadcastChannel. Without them, open the lesson in presentation mode and use its own controls.

The two windows talk to each other only inside this browser, on this device. Nothing is sent to a server, and no account is needed. A second device (a phone or another tablet) cannot follow the lesson window yet.

Lesson plan

Level
Beginner
Time
About 55 minutes; the steps below add up to 55

Learners first work out that an IP address only reaches the device and something else must choose the program. Ports, agreed service numbers and sockets follow from that need. TCP and UDP are then introduced through a choice learners can judge for themselves (a download against a live call), and the panel lets them see what each actually delivers when part of a message is lost or arrives out of order, and what TCP's promise costs.

Objectives

  • Explain why a device needs port numbers as well as an IP address
  • Recognise the common service ports and the three port ranges
  • Explain what a socket is, and how one server port serves many connections
  • Compare TCP and UDP, and predict what each delivers when data is lost or arrives out of order
  • Tell transport ports apart from physical switch ports, IP addresses and MAC addresses

Before the lesson

  • Open this page on your own screen and use “Open the lesson window” to open the lesson in a second window. Share only that second window.
  • Try the TCP and UDP panel once with each fault before the lesson, then reset it from this page.
  • Learners need the IP addresses lesson first. If some have not done it, describe an IP address as the device’s address on the network and carry on.
  • The lesson takes about 55 minutes.
  • In presentation mode every step is shown in turns: Next reveals one moment, part or answer at a time, and the instructor view names what is on screen and what comes next.

Steps

  1. Introduction Opening

    On screen: the lesson’s title, module and number; Next adds its objectives and key terms, as the lesson page lists them; Next again begins the first step.

    Objectives on screen

    • Explain why a device needs port numbers as well as an IP address
    • Recognise the common service ports and the three port ranges
    • Explain what a socket is, and how one server port serves many connections
    • Compare TCP and UDP, and predict what each delivers when data is lost or arrives out of order
    • Tell transport ports apart from physical switch ports, IP addresses and MAC addresses

    Purpose: Learners first work out that an IP address only reaches the device and something else must choose the program. Ports, agreed service numbers and sockets follow from that need. TCP and UDP are then introduced through a choice learners can judge for themselves (a download against a live call), and the panel lets them see what each actually delivers when part of a message is lost or arrives out of order, and what TCP's promise costs.

  2. 1. Which program is it for? Think 5 min

    Purpose: Create the need for ports before naming them: an address reaches the device, not the program.

    Ask

    • Three programs, one laptop, one address. How does arriving data find the right program?
    • What gets a letter to the right person in a large building?

    Responses to expect

    • “A name”, “a number”, “the program’s address”. Any second identifier is the right idea; then name it a port.
    • On screen in turns: the opening question, its answer.

    Discussion pause: Let a few learners answer before revealing.

    In the lesson window

    • Think it through: Your laptop has a web browser, an email app and a music app all using the internet at the same moment. Some data arrives, addressed to your laptop’s IP address. How could the laptop know which program the data is for?
  3. 2. Why ports exist Explain 10 min

    Purpose: Explain ports with the block-of-flats comparison, show why services use agreed numbers, and correct the belief that a port number guarantees a service.

    Ask

    • If every website picked a random port, what would visitors need to know?
    • Which flat number would you ask for to reach a secure website?
    • Traffic on port 443: is it certainly HTTPS?

    Responses to expect

    • Some think random ports add security; ask how visitors would find the site.
    • The 443 question often draws “yes”. Make the point that ports are conventions.
    • On screen in turns: the opening; then the IP address as the building, and the port as the flat; what a port is, and is not; the question on agreed port numbers, and its answer; the common services and their ports; the three port ranges, and the client’s temporary port; where the flats comparison stops; the check question on port 443, and its answer.

    Misconceptions to challenge

    • A learner may believe: “Well-known ports guarantee which service is running.” Respond: They are conventions. Anything can be set up on any port.
    • A learner may believe: “A port is a physical socket.” Respond: Here it is a number carried with the data. Physical switch ports come later in the lesson.

    If the explanation does not land: Use a school: the school’s address gets a parcel to reception; the room number gets it to the right class.

    In the lesson window

    • Think it through: A web server waits for visitors. Suppose every website chose its own random port number. What problem would visitors have?
    • Check your understanding: A log shows traffic to port 443 on a server. Can you be certain that the traffic is HTTPS?
  4. 3. Sockets Discover 7 min

    Purpose: Explain sockets as one program’s end of one connection, and show how temporary source ports keep connections apart.

    Ask

    • Two tabs, one server port. How does each reply reach its own tab?

    Responses to expect

    • Some suggest the server uses another port; point to the example, where only the source port differs.
    • On screen in turns: the opening; then a connection identified by five things; the question on two browser tabs, and its answer; two tabs, one server, starting with the first tab; the second tab; the server’s replies; what changed.

    If the explanation does not land: Two people in the same family phone the same call centre: the centre’s number is the same, but each call is a separate line, told apart by the caller’s own number.

    In the lesson window

    • Think it through: You open the same website in two browser tabs. Both connect to the server’s port 443. When the server replies, how does each reply reach the right tab?
  5. 4. TCP and UDP Experiment 9 min

    Purpose: Introduce TCP and UDP through a choice learners can judge, then predict, try and explain what each delivers.

    Ask

    • Download or live call: wait for the missing part, or carry on?
    • Predict: part 3 is lost. What does the program get with TCP? With UDP?
    • Now try the panel. Count the messages in each case. What does TCP’s promise cost?

    Responses to expect

    • Most predict correctly for TCP. Fewer predict UDP’s output; the panel makes it concrete.
    • With parts arriving out of order, UDP delivers them in the order they arrived: “Your exam are results ready”. Use the oddness of the sentence.
    • Panel: after the prediction, try TCP and UDP with the third word lost, and count the messages each needs.
    • On screen in turns: the opening; then the question on a lost part of a call or a download, and its answer; TCP and UDP compared; the TCP handshake, then reliable data; UDP: just send.

    Misconceptions to challenge

    • A learner may believe: “UDP is just a worse TCP.” Respond: It is lighter and faster. For a call or a quick lookup, resending would only add delay.
    • A learner may believe: “Anything over UDP is unreliable and unencrypted.” Respond: Protocols built on UDP, such as QUIC for HTTP/3, add their own reliability and encryption.

    Discussion pause: Ask pairs to name one job for each transport before moving on.

    If the explanation does not land: Act it out: one learner reads a sentence word by word to another, who must write it down; then repeat with one word dropped, once asking again for it and once not.

    In the lesson window

    • Think it through: Part of a message goes missing on the way. For a file download, the missing part must be sent again. For a live video call, what is better: waiting for the missing part, or skipping it and carrying on?
  6. 5. Try it: losing a part with TCP and UDP Experiment 6 min

    Purpose: Let learners predict what each transport delivers when a part is lost, then test the prediction in the panel.

    Responses to expect

    • Panel: after the prediction, try TCP and UDP with the third word lost, and count the messages each needs. The panel is on screen when the step opens, so the instructor view’s jump to this step lands on it.
    • On screen in turns: the opening question, its answer; then why UDP is not a weakness for every job; the check question on copying a large file, and its answer.

    In the lesson window

    • Think it through: A five-part message, “Your exam results are ready”, is sent one word at a time. The third part is lost on the way. Before you try the panel below: what does the receiving program get with TCP, and with UDP?
    • Check your understanding: A program must copy a large file between two servers, and the copy is useless if any part is missing or out of order. Which transport fits, and why?
    • TCP and UDP demonstration
  7. 6. Addresses, ports and sockets answer different questions Explain 7 min

    Purpose: Separate the five identifiers, especially the two meanings of “port”.

    Ask

    • “The laptop is on port 5” and “the browser connected to 443”: same kind of port?

    Responses to expect

    • Most will say no once they see the table; ask for the hardware one to be pointed at.
    • On screen in turns: the opening; then five identifiers, starting with the IP address; the MAC address; the TCP or UDP port; the physical switch port; the socket; the two meanings of port; why a MAC address is not proof of identity; the check question on two kinds of port, and its answer; ports in firewall rules.

    Misconceptions to challenge

    • A learner may believe: “Port 443 is a socket on the switch.” Respond: 443 is a number in software. Port 5 on a switch is a hole for a cable.
    • A learner may believe: “A MAC address proves which device it is.” Respond: MAC addresses can be changed, randomised or copied.

    Discussion pause: Reveal the identifiers one at a time; ask the class what question each answers before its row appears.

    In the lesson window

    • Check your understanding: One technician says: “The laptop is on port 5.” Another says: “The browser connected to port 443.” Are they talking about the same kind of port?
  8. 7. Apply it in a new situation Apply 4 min

    Purpose: Set up independent application, ideally on a later day.

    Ask

    • Who will try these now, and who will come back to them later in the week?

    Responses to expect

    • The game question mirrors the video call; the firewall question previews the firewall lesson.
    • On screen in turns: the opening question, its answer; then the question on the secure-site rule, and its answer.

    In the lesson window

    • Apply it: An online game sends every player’s position thirty times a second. A position that arrives late is useless, because a newer one has already replaced it. Which transport suits these updates better?
    • Apply it: A school’s secure website runs on its web server in the normal way. Staff at home must be able to reach it and nothing else on that server. Which firewall rule fits best?
  9. 8. Check your understanding Check 4 min

    Purpose: Check the lesson against the approved revision-bank questions.

    Ask

    • Answer individually, then compare before revealing.

    Responses to expect

    • The handshake order is the one most often muddled: SYN, SYN-ACK, ACK.
    • On screen in turns: the opening; then the revision questions one at a time, each followed by its answer; where to practise next.
  10. 9. What to remember Consolidate 3 min

    Purpose: Summarise ports, sockets and the two transports, and the two meanings of port.

    Ask

    • Without looking: what does the IP address find, and what does the port find?

    Responses to expect

    • The device, and the program on it.
    • On screen in turns: the opening; then the summary; the common misunderstandings.
  11. Lesson recap Closing

    On screen: the lesson’s objectives again; Next adds the closing question, which asks the class to explain each one in their own words without looking back. It says nothing about what anyone has learnt: use the answers to decide what to revisit.

    Points to listen for

    • The IP address finds the device; the port number finds the program on it.
    • Well-known ports are conventions, not guarantees.
    • A socket is one program’s end of one connection.
    • TCP delivers everything in order at the cost of extra messages; UDP sends and moves on.
    • A transport port is a number; a switch port is hardware.

Consolidation

  • The IP address finds the device; the port number finds the program on it.
  • Well-known ports are conventions, not guarantees.
  • A socket is one program’s end of one connection.
  • TCP delivers everything in order at the cost of extra messages; UDP sends and moves on.
  • A transport port is a number; a switch port is hardware.