The Transport Layer, Explained

UPI Study › Courses › Introduction to Operating Systems › Free lessons › Lesson 7.6 Free with a free account

The Transport Layer

Introduction to Operating Systems · Chapter 7: Computer Networks: Architecture, Layers, and ProtocolsSection 7.6 · lesson 61 of 838 min · free with a free account

← The Presentation LayerNext lesson: The Session Layer →

A free account plays all of Chapter 1 and 3 more lessons of Introduction to Operating Systems. Create a free account →

Earn 3 college credits for Introduction to Operating SystemsRecommended for credit by NCCRS · Computer Science 354 · self-paced · one payment, lifetime access

In this lesson

How ports, TCP and UDP deliver data between programs.

  • Explain how 16-bit port numbers identify programs and name a connection
  • Identify well-known ports for HTTP, HTTPS, DNS, SSH and SMTP
  • Compare TCP and UDP and choose the right one for an application
  • Trace the TCP three-way handshake and explain flow control and retransmission

Free study notes

Get this lesson's notes by email

The key points and 4 practice questions with answers, in your inbox. One email, free.

One email. Unsubscribe in one click.

Transcript

Everything said in the video, section by section (1,046 words). Read along, or search it.

Opening Question

Apartment Numbers and Delivery Choices

A street address gets a letter to the right building. But a building holds many people, so the letter also needs an apartment number. And you choose how to send it: as a registered letter, signed for at the other end, or as a postcard you drop in a box and forget. Computers face the same two choices. Which program should get the data? And how careful should the delivery be?

Ports

Numbers That Pick the Program

The network layer, from lesson 7.4, delivers packets to the right computer. But which program on that computer should get them? Sam, who runs a small online bakery, has a browser, a mail app and an update service all running on one laptop. The transport layer, layer 4, answers with ports: 16-bit numbers, from 0 to 65535, that name a program on a machine. Its job is end to end. It joins a program on one computer to a program on another, whatever routers lie between.

Well-Known Ports

Ports 80, 443, 53, 22 and 25

Servers use well-known ports, from 0 to 1023, so clients know where to knock. Five you'll meet often. Port 80 is plain web pages, and 443 is the secure web. 53 is DNS, for looking up names. 22 is SSH, for secure remote logins. And 25 is SMTP, which moves email between mail servers. A client's own port is picked by its OS from a high range, a fresh one for each connection. So one connection is named by four values: the two IP addresses, and the two ports. That's how many browser tabs can talk to the same server, on port 443, at once. Each tab gets its own client port. A socket holds this pairing: lesson 8.5.

TCP and UDP

Registered Letter or Postcard

Layer 4 offers two main protocols. TCP, the Transmission Control Protocol, is the registered letter. It sets up a connection first, numbers the data, checks that every part arrives, puts the parts back in order, and slows down if the receiver is swamped. UDP, the User Datagram Protocol, is the postcard. It addresses a small message with ports, and sends it. If the message is lost, UDP doesn't notice. Neither one is better. UDP is a deliberate choice, not a broken TCP. A web page with a missing piece is useless, so the web uses TCP. In a video call, a few lost milliseconds of sound barely matter. But waiting for a resend would make the call stutter, so calls use UDP. And DNS lookups usually use UDP too. The question and the answer are tiny, and a lost one is simply asked again.

Quick Check

Which Lab Program Needs UDP

Quick check. Ivy, who looks after the computers at a school, is setting up three programs for the computer lab. Which one should use UDP: downloading a lesson PDF, submitting an online quiz, or sending a game's live position updates? Pause, and decide. The game's position updates. A position that arrives late is already out of date, so resending it only adds delay. The next update replaces it anyway. The PDF and the quiz answers must arrive complete, and in order. A missing piece would ruin them, so they use TCP.

Three-Way Handshake

SYN, SYN Plus ACK, Then ACK

Before TCP carries any data, the two ends must agree to talk, and agree on starting numbers. That takes three short messages. First, the client sends a SYN, short for synchronize, with its starting number: say, 100. The server replies with a SYN plus ACK: its own start, 5000, and an acknowledgment, 101. That says: got your SYN, send byte 101 next. Finally, the client sends an ACK: 5001. Now both ends know the other is alive and listening, and data can flow both ways. The SYN itself uses up one number. That's why each acknowledgment is the other side's start, plus one.

Quick Check

The Server's Acknowledgment Number

Quick check. This time, the client starts at sequence number 700, and the server at 9000. What acknowledgment number does the server put in its SYN plus ACK: 700, 701, or 9001? Pause, and decide. 701. It acknowledges the client's SYN, which used up number 700, so the next byte it expects is 701. 9001 is tempting, but that's the client's job, in the third message: it acknowledges the server's start, plus one.

Flow Control

The Receiver Window Slows the Sender

TCP also protects a slow receiver. The receiver announces its window: how many bytes it has room for, right now. The sender may have at most that many bytes on the way, not yet acknowledged. Say the window is 4000 bytes, and a segment carries up to 1460. That's two full segments, and part of a third. Then the sender must wait. That's flow control. A fast server can't flood a slow phone.

Reliability

Timers, ACKs and Retransmission

So how does TCP make an unreliable network feel reliable? Every part carries a number, and the receiver sends back an acknowledgment, an ACK, for what arrived. When the sender sends a part, it starts a timer. If no ACK has come back when the timer runs out, it assumes the part was lost, and sends it again. That's a retransmission. And the numbers let the receiver put parts back in order, and drop any duplicates.

Simulation

Eight Parts Over a Lossy Wire

Here's what that buys, in a simulation run in Python. Eight parts cross a wire that loses about thirty percent of all messages, ACKs included. Sent UDP style, just once each, only five of the eight parts arrived, and the sender never knew. Sent TCP style, resending until an ACK comes back, all eight arrived, in order. The price: twenty-one transmissions instead of eight.

Real Example

Why Calls Skip and Copies Do Not

Sam once asked Ivy why a video call drops a word now and then, while a file copy never loses a byte. Different layer 4 choices, Ivy said. The call uses UDP, so a lost packet is skipped, and the call keeps moving. The copy uses TCP, so every lost piece is sent again. And back to the letter. The IP address finds the building. The port finds the door. And TCP or UDP decides: registered letter, or postcard.

Key Takeaways

Ports, TCP, UDP and the Handshake

To recap. Ports are 16-bit numbers that pick the program: 80 and 443 for the web, 53 for DNS, 22 for SSH, and 25 for mail between servers. TCP connects first, numbers everything, and resends what's lost. UDP just sends. A TCP connection opens with a three-way handshake: SYN, SYN plus ACK, then ACK. And the receiver's window keeps a fast sender from flooding a slow one.

About Introduction to Operating Systems at UPI Study

Introduction to Operating Systems (Computer Science 354) is a self-paced online course of 83 video lessons in 10 chapters, from what an operating system does and process scheduling to concurrency, memory, devices, file systems, networks, the internet, security and virtual machines. It carries a NCCRS credit recommendation for 3 semester credits.

Every lesson transcript is free on pages like this one, and the videos are free with a free UPI Study account. Enrolling adds a practice quiz after each lesson, the graded work and final exam that earn the credit, lifetime access, and an official transcript on completion. UPI Study has helped over 130,000 students with college credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.

Compare: Linux vs Operating Systems

Why take it here

Why students take Introduction to Operating Systems with UPI Study

What happens under every app you runIntroduction to Operating Systems explains the software that runs a computer: processes and scheduling, threads and synchronization, deadlock, memory and paging, devices and storage, file systems, networking, security and virtualization. It suits computer science and information technology degrees.
Credit at a fraction of the priceThe same 3 credits can cost $750 or more at a US college. Here it is one payment, self-paced, with lifetime access.
Finish your degree soonerTransfer credits reduce the courses you still owe, so you can graduate earlier or lighten a heavy semester.
Strengthen an applicationA completed college-level course on an official transcript shows admissions and scholarship committees you can do the work.
Study on your own scheduleNo start dates, no deadlines. Watch the lessons, practice, and take the final when you are ready.
130,000+students helped with college creditsACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.

Where the credit goes

Universities that work with NCCRS

Introduction to Operating Systems carries a NCCRS credit recommendation. These universities work with NCCRS; some are UPI Study's signed partners. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.

Find my college → Not listed? Ask Athena in the corner of this page, or book a 15-minute call.

FAQ

Questions students ask us

About The Transport Layer

What is the difference between TCP and UDP?
TCP sets up a connection and makes delivery reliable, while UDP simply sends each message without checking that it arrived. TCP numbers the data, waits for acknowledgments, resends lost parts, restores order and slows down for a busy receiver. UDP skips all of that, which makes it a good fit for live calls, games and quick lookups where a late resend would be useless.
How does the TCP three-way handshake work?
The TCP three-way handshake opens a connection with three messages: SYN, SYN plus ACK, then ACK. The client sends a SYN with its starting number, say 100. The server answers with its own start, say 5000, and acknowledges 101. The client then acknowledges 5001. Each acknowledgment is the other side's start plus one, because a SYN uses up one sequence number.
What are the common well-known port numbers?
Common well-known ports include 80 for plain web pages, 443 for secure web pages, 53 for DNS, 22 for SSH and 25 for SMTP mail between servers. Well-known ports run from 0 to 1023 so clients know where to find a service. A client's own port is picked by its operating system from a high range, with a fresh one for each connection.
What is TCP flow control?
TCP flow control keeps a fast sender from overwhelming a slow receiver. The receiver advertises a window, the number of bytes it has room for right now, and the sender may have at most that many unacknowledged bytes in flight. With a 4,000-byte window and segments of up to 1,460 bytes, the sender can send two full segments and part of a third before it must wait.

About the Introduction to Operating Systems course

How many college credits is Introduction to Operating Systems?
Introduction to Operating Systems (Computer Science 354) carries a NCCRS credit recommendation for 3 semester credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
How much does Introduction to Operating Systems cost and what is included?
$250, paid once, with lifetime access: all 83 video lessons, a practice quiz after each, the graded work and final exam, and an official transcript when you finish. Students who want several courses choose UPI Study PRO instead.
Which universities accept UPI Study credits?
UPI Study has signed partner agreements with universities such as Thomas Edison State University, University of the People and Charter Oak State College, and works with universities such as Penn State, SNHU and SUNY. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities. Use "Find my college" on this page to check yours.
How long does Introduction to Operating Systems take?
It is self-paced with no deadlines. The 83 lessons total about 10 hours of video; most students add reading and practice time and finish in a few weeks to a few months, on their own schedule.
How are the exams done?
Quizzes and assignments are online in the course. The final exam is taken online with proctoring; a person on the UPI Study team checks assignments, usually within two days.
How do my credits reach my college?
When the course shows 100% complete, request the official transcript from your dashboard. It is sent to the college you name, and you can send it to more than one. Check your college first with "Find my college" on this page, or ask Athena.

Ready for the full course? Earn 3 credits in Introduction to Operating Systems.

83 video lessons, a quiz after each one, and the graded work that earns the credit. Recommended for credit by NCCRS.

Updated

Introduction to Operating Systems
3 credits · NCCRS
Enroll →