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
Free preview
Create a free account to keep watching
It takes a minute and costs nothing. Your free account unlocks all of Chapter 1 and 3 more lessons of Introduction to Operating Systems.
Lesson complete
Earn the 3 college credits for Introduction to Operating Systems
Enrolling adds a quiz after each lesson, the graded work and the official transcript. Recommended for credit by NCCRS.
Next lesson: The Session Layer →← 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 →
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.
Enroll now → Course details Download the syllabus All Computer Science courses Every course with PRO →
Compare: Linux vs Operating Systems
Why take it here
Why students take Introduction to Operating Systems with UPI Study
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.
Thomas Edison State UniversitySigned partner
University of the PeopleSigned partner
Charter Oak State CollegeSigned partner
Strayer UniversitySigned partner
Columbia Southern UniversitySigned partner
Indiana TechSigned partner
Penn StateWorks with NCCRS
Southern New Hampshire UniversityWorks with NCCRS
SUNYWorks with NCCRS
+many more cooperating universitiesFind my college →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?
How does the TCP three-way handshake work?
What are the common well-known port numbers?
What is TCP flow control?
About the Introduction to Operating Systems course
How many college credits is Introduction to Operating Systems?
How much does Introduction to Operating Systems cost and what is included?
Which universities accept UPI Study credits?
How long does Introduction to Operating Systems take?
How are the exams done?
How do my credits reach my college?
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
3 credits · NCCRSEnroll →