IT131 · SESSION 10 · FIELD NOTES

Transport & Application Layers

Logistics can now get a packet to any address on the planet. But a PC runs a browser, an email client, and a DNS lookup all at once, so which program gets which package? This week we go up two floors: Shipping & Receiving (Layer 4), which numbers, tracks, and re-sends parcels, and the Front Desk (Layer 7), where the protocols you actually use every day live.

New material Module 14 — Transport Layer New material Module 15 — Application Layer Next week Module Quiz — Network Application Communications (14–15)

Modules 14 & 15

What Session 10 covers

Two modules. Module 14 is the transport layer: TCP, UDP, port numbers, and how TCP sets up, tracks, and tears down a conversation. Module 15 is the application layer: the protocols behind the web, email, name lookups, automatic addressing, and file sharing. Next week's checkpoint quiz covers both.

Cold open · Shipping & Receiving, Floor 4

Logistics drops off a pallet with three hundred boxes, all addressed to the same building. "Same building," says the Shipping clerk, "but which office?" She checks the labels. Desk 80 is the web team, desk 53 is the directory desk, and desk 49712 is a temp who started this morning. Some boxes are marked signature required, so she numbers them, waits for receipts, and re-sends anything that never got signed for. Others are marked just drop it off. Those go out fast with no receipts. Those two delivery styles are TCP and UDP.

Topology used on this page The same two routers as Sessions 7–9. PC-A is 192.168.10.10 on R1's LAN (192.168.10.0/24). PC-B is 192.168.20.10 on R2's LAN (192.168.20.0/24). New this week: SRV1 at 192.168.20.100 on R2's LAN. It's a web server (TCP 80 and 443) and the internal DNS server for the zone it131.example.

Module 14 · 14.1

What the transport layer does

The network layer gets a packet to the right host. The transport layer gets the data to the right application on that host, and decides how carefully to deliver it.

JobWhat it means
Track individual conversationsA host may have many applications talking at once. Each conversation is tracked separately.
Segment and reassemble dataBig application data is split into pieces small enough to send, then put back together at the other end.
Add header informationPort numbers (and, for TCP, sequence numbers and more) so the receiver knows where each piece belongs.
Identify the applicationThe port number says which application the data is for.
Conversation multiplexingSegments from many conversations are interleaved on the same link, so one big download doesn't block everything else.

The two transport protocols are TCP and UDP. Neither is "better": Cisco NetAcad's phrase is the right protocol for the right application.

Module 14 · 14.2–14.3

TCP vs. UDP

TCP is signature-required delivery: it tracks every byte. UDP is "just drop it off": fast, with almost no overhead.

TCPUDP
ConnectionConnection-oriented: a three-way handshake before any dataConnectionless: no setup
ReliabilityAcknowledgments and retransmissionBest effort: no ACKs, no retransmission
OrderingSame-order delivery, using sequence numbersNo resequencing. Data is reassembled in the order it arrives.
Flow controlYes (window size)No
StateStateful: tracks the sessionStateless
Header20 bytes minimum8 bytes, fixed
PDU nameSegmentDatagram
Typical appsHTTP, HTTPS, FTP, SMTP, POP3, IMAP, SSH, TelnetDHCP, DNS queries, SNMP, TFTP, VoIP, video streaming and conferencing
UDP isn't "broken TCP" A voice call would rather lose a tenth of a second of audio than pause while it waits for a retransmission, because by then the moment has passed. And an application that needs reliability over UDP can build its own. TFTP does exactly that, with simple acknowledgments of its own.

The TCP header (10 fields)

TCP header, 32 bits per row
bit 0 16 31 +-----------------+-----------------+ | Source Port | Dest. Port | +-----------------+-----------------+ | Sequence Number (32) | +-----------------------------------+ | Acknowledgment Number (32) | +------+------+-----+---------------+ |HdrLen| Rsvd |Flags| Window Size | | (4) | (6) | (6) | (16) | +------+------+-----+---------------+ | Checksum (16) | Urgent (16) | +-----------------+-----------------+ | Options (if any) + Data |
FieldWhat it's for
Source / Destination PortWhich application sent it, and which should receive it.
Sequence NumberNumber of the first data byte in this segment. Used to put data back in order.
Acknowledgment NumberThe next byte expected from the other side.
Header LengthLength of the TCP header (also called data offset).
ReservedReserved for future use.
Control BitsThe flags: URG, ACK, PSH, RST, SYN, FIN (see the handshake section).
Window SizeHow many bytes the receiver can accept at one time. This is flow control.
ChecksumError check on the header and data.
UrgentMarks urgent data, used with the URG flag.
Footnote: modern TCP has 8 flags NetAcad draws 6 reserved bits and 6 flags, which is the original 1981 layout. Current TCP uses 4 reserved bits and adds two congestion flags (CWR, ECE), and Wireshark will show them. For the exam, answer 6 flags.

The UDP header (4 fields, 8 bytes)

UDP header: that's the whole thing
bit 0 16 31 +-----------------+-----------------+ | Source Port | Dest. Port | +-----------------+-----------------+ | Length | Checksum | +-----------------+-----------------+ | Data |

No sequence numbers, no acknowledgments, no window. That's where the low overhead comes from.

Module 14 · 14.4

Port numbers, sockets, and netstat

The IP address gets the data to the building. The port number gets it to the right desk.

RangeNameUsed for
0 – 1023Well-known portsCommon server services, like HTTP 80 and DNS 53.
1024 – 49151Registered portsAssigned by IANA to specific applications on request.
49152 – 65535Private and/or dynamic portsPicked on the fly as a client's source port. Also called ephemeral ports.

Well-known ports to memorize

PortProtocolTransport
20FTP dataTCP
21FTP controlTCP
22SSHTCP
23TelnetTCP
25SMTPTCP
53DNSUDP and TCP
67 / 68DHCPv4 server / clientUDP
69TFTPUDP
80HTTPTCP
110POP3TCP
143IMAPTCP
161SNMPUDP
443HTTPSTCP

DNS uses UDP for ordinary lookups and TCP for zone transfers between servers and for very large responses. NetAcad just says "both". (The when-each detail is enrichment.)

Try it: look up a port or a protocol

Sockets and socket pairs

PC-A opens two browser tabs to SRV1's web page. They are two different conversations:

Three socket pairs from PC-A
tab 1 192.168.10.10:49712 ↔ 192.168.20.100:80 tab 2 192.168.10.10:49713 ↔ 192.168.20.100:80 SSH 192.168.10.10:49731 ↔ 192.168.10.1:22

The server's socket is the same for both tabs. SRV1 tells them apart by the client's source port. That's multiplexing in action.

netstat: see your connections

PC-A · netstat (names resolved)
C:\Users\student> netstat Active Connections Proto Local Address Foreign Address State TCP 192.168.10.10:49712 srv1:http ESTABLISHED TCP 192.168.10.10:49713 srv1:http TIME_WAIT TCP 192.168.10.10:49720 srv1:https ESTABLISHED TCP 192.168.10.10:49731 192.168.10.1:ssh ESTABLISHED
PC-A · netstat -an (numeric, and all, including listeners)
C:\Users\student> netstat -an Active Connections Proto Local Address Foreign Address State TCP 0.0.0.0:135 0.0.0.0:0 LISTENING TCP 0.0.0.0:445 0.0.0.0:0 LISTENING TCP 192.168.10.10:139 0.0.0.0:0 LISTENING TCP 192.168.10.10:49712 192.168.20.100:80 ESTABLISHED TCP 192.168.10.10:49713 192.168.20.100:80 TIME_WAIT TCP 192.168.10.10:49720 192.168.20.100:443 ESTABLISHED TCP 192.168.10.10:49731 192.168.10.1:22 ESTABLISHED UDP 0.0.0.0:123 *:* UDP 192.168.10.10:137 *:*
What you seeWhat it means
Local / Foreign AddressPC-A's socket, and the remote socket. PC-A's ports are all 49152+, picked by Windows. The server ports (80, 443, 22) are well-known.
ESTABLISHEDHandshake done; the connection is open.
LISTENINGA local service waiting for connections. 0.0.0.0 means "on every local address". Only shows with -a.
TIME_WAITRecently closed. PC-A sent the first FIN, so it holds the socket briefly in case late segments arrive. Normal; it clears on its own.
UDP rows: no state, *:*UDP is connectionless, so there's no connection to describe.
NetAcad's netstat screenshot is old The course's netstat example shows source ports like 3126. That's the pre-Vista range (1025–5000). Current Windows uses 49152–65535, which is what you'll see in lab. Plain netstat and -n are in NetAcad. The -a flag and the state names other than ESTABLISHED are light enrichment.

Module 14 · 14.5

Opening and closing a TCP connection

Before TCP sends a single byte of data, the two hosts shake hands. When they're done, each side says goodbye separately.

The six control flags

FlagMeaning
URGThe Urgent field is significant
ACKThe Acknowledgment field is significant. Set on every segment after the first SYN.
PSHPush: hand this data to the application now
RSTReset the connection (error, refused, or timeout)
SYNSynchronize sequence numbers: used to open a connection
FINNo more data from the sender: used to close

Three-way handshake

PC-A (192.168.10.10:49712) connects to SRV1 (192.168.20.100:80). Numbers are relative, as Wireshark shows them: each side's starting number is shown as 0.

#DirectionFlagsSEQACK
1PC-A → SRV1SYN0—
2SRV1 → PC-ASYN, ACK01
3PC-A → SRV1ACK11

NetAcad gives the handshake three jobs:

  1. 1. It establishes that the destination device is present on the network.
  2. 2. It verifies that the destination has an active service accepting requests on that port.
  3. 3. It tells the destination that the source intends to set up a session on that port.
The three rules that make the numbers work 1. ACK = the next byte expected = received SEQ + data length.
2. SYN and FIN each use up one sequence number, even though they carry no data. That's why the ACK to a SYN is ISN + 1.
3. A pure ACK (no data) does not move the sender's sequence number forward.

Real starting numbers (ISNs) are random 32-bit values like 2,814,005,331. Relative numbering just subtracts them. The pattern is what matters, not the starting value.

Four-step termination

Continuing the same connection after PC-A sent 400 bytes and SRV1 sent 2,920:

#DirectionFlagsSEQACK
1PC-A → SRV1FIN, ACK4012921
2SRV1 → PC-AACK2921402
3SRV1 → PC-AFIN, ACK2921402
4PC-A → SRV1ACK4022922

The client sends FIN, the server ACKs, the server sends its own FIN, and the client ACKs. Each direction closes on its own. Notice the FIN uses up one number: 401 → 402, 2921 → 2922.

Wireshark often shows three, not four If the server has nothing left to send, it combines steps 2 and 3 into a single FIN, ACK. The exam answer is still four steps.

Try it: build a whole TCP conversation

Module 14 · 14.6

Reliability and flow control

Sequence numbers put the data back in order. Acknowledgments say what arrived. The window keeps the sender from flooding the receiver.

Ordered delivery

Segments can take different paths and arrive out of order. The receiver uses sequence numbers to hold early arrivals until the gaps fill, then hands the data to the application in the original order.

Data transfer, byte by byte

DirectionFlagsSEQACKDataWhy
PC-A → SRV1PSH, ACK11400HTTP GET: bytes 1–400
SRV1 → PC-AACK140114601 + 400 = 401: "send byte 401 next"
SRV1 → PC-APSH, ACK146140114601 + 1460 = 1461
PC-A → SRV1ACK40129210One ACK covers both segments. PC-A's SEQ stays 401, because it sent no new data.

Lost data and retransmission

If the sender doesn't get an ACK in time, it re-sends. ACKs are cumulative: an ACK of 1461 means "I have everything before byte 1461". So if the middle segment of three is lost, the receiver can only keep ACKing up to the gap.

Window size and MSS

Window sizeMSS (maximum segment size)
What it limitsHow many unacknowledged bytes can be in flightHow much data fits in one segment
Who sets itThe receiver advertises it in every segmentEach host announces its own in the SYN
Typical valueVaries, and changes during the connection1460 bytes = 1500 MTU − 20 IPv4 header − 20 TCP header

Sliding window: the receiver doesn't wait for the whole window before ACKing. It keeps sending ACKs with an updated window size, so the window "slides" forward and the sender rarely has to stop. If the receiver's buffer fills, it advertises a smaller window and the sender slows down. That's flow control.

"Agreed" vs. "announced" NetAcad's wording suggests the window size is agreed during the handshake. Strictly, each side announces its own window and MSS; nobody negotiates. Either wording gets the same exam answer.

Congestion avoidance

When the network is congested, routers drop packets, and retransmissions make the congestion worse. When TCP detects loss, the source reduces how much unacknowledged data it sends. NetAcad stresses it's the sender doing this, not the receiver's advertised window. The actual algorithms are beyond this course.

Preview, not on the NetAcad exam The real mechanisms are slow start, the congestion window (cwnd), and fast retransmit. You'll meet them in later courses.

Module 14 · 14.7

UDP in action

UDP is simple, and that's the point.

Module 15 · 15.1

Application, presentation, and session

In the TCP/IP model, OSI Layers 5, 6, and 7 are combined into one application layer. In the OSI Company: the Front Desk (L7), Translation & Wardrobe (L6), and Scheduling (L5).

OSI layerJobExamples
7 · ApplicationInterface between the user's programs and the networkDNS, DHCP, SMTP, POP3, IMAP, FTP, TFTP, HTTP, HTTPS
6 · PresentationFormats, compresses, and encrypts dataJPEG, GIF, PNG, MPEG, QuickTime
5 · SessionCreates and maintains dialogs, and restarts sessions that are interrupted or idle—
Protocol familyProtocols
Name systemDNS
Host configurationDHCP (and its ancestor, BOOTP)
EmailSMTP, POP3, IMAP
File transferFTP, SFTP, TFTP
WebHTTP, HTTPS, REST

Module 15 · 15.2

Client-server and peer-to-peer

Who asks and who answers?

Client-serverPeer-to-peer (P2P)
RolesA dedicated server answers; clients requestEvery device can be client and server, request by request
ResourcesCentralized on the serverSpread across the peers
ExampleA browser and a web serverTwo PCs sharing a folder or printer, with no server

Module 15 · 15.3

Web and email protocols

The two protocol families you use most.

The web: HTTP and HTTPS

Parts of a URL
http://www.it131.example/index.html └┬─┘ └──────┬────────┘ └───┬────┘ protocol server name requested file (DNS resolves it)

Email: one protocol to send, two to receive

Email clients never talk directly to each other. Mail goes client → server → server → client.

ProtocolJobPortMail kept on the server?
SMTPSends: client → server, and server → server. If the destination server is busy, SMTP spools the message and retries.TCP 25—
POP3Retrieves: downloads mail to the clientTCP 110No. Downloaded, then deleted from the server. Bad for multiple devices.
IMAPRetrieves: the client gets copiesTCP 143Yes, until the user deletes it. Folders sync across devices.
Memory hook SMTP Sends. POP Pulls it off the server. IMAP keeps it In the Mailbox. (Real POP3 clients often have a "leave a copy on server" option, but NetAcad's answer is that POP deletes.)

Module 15 · 15.4

IP addressing services: DNS and DHCP

DNS turns names into addresses. DHCP hands out addresses in the first place.

DNS

RecordHolds
AAn end device's IPv4 address
AAAAAn end device's IPv6 address ("quad-A")
NSAn authoritative name server
MXA mail exchange server
PC-A · nslookup (interactive mode)
C:\Users\student> nslookup Default Server: srv1.it131.example Address: 192.168.20.100 > www.it131.example Server: srv1.it131.example Address: 192.168.20.100 Name: www.it131.example Address: 192.168.20.100 > www.example.net Server: srv1.it131.example Address: 192.168.20.100 Non-authoritative answer: Name: www.example.net Address: 203.0.113.80 > exit
LineWhat it means
Default Server / AddressThe DNS server PC-A is configured to use.
No "Non-authoritative" lineSRV1 owns the it131.example zone, so it answered from its own records.
Non-authoritative answerSRV1 doesn't own example.net. It got the answer from other servers (or its cache) and passed it on. Not an error.
"Default Server: UnKnown" is usually harmless If the DNS server has no reverse (PTR) record for its own address, nslookup prints Default Server: UnKnown, sometimes after a timeout. Lookups still work. Also note that nslookup asks the DNS server directly and skips the PC's cache and hosts file, so it can disagree with what ping resolves.
PC-A · ipconfig /displaydns (the local DNS cache)
C:\Users\student> ipconfig /displaydns Windows IP Configuration www.it131.example ---------------------------------------- Record Name . . . . . : www.it131.example Record Type . . . . . : 1 Time To Live . . . . : 3542 Data Length . . . . . : 4 Section . . . . . . . : Answer A (Host) Record . . . : 192.168.20.100

Record Type 1 is an A record (AAAA shows as 28). The TTL counts down in seconds, and the entry disappears when it hits 0. ipconfig /flushdns empties the cache, which is useful after a DNS record changes. (/flushdns is enrichment.)

DHCPv4

DHCP automatically gives a host its IP address, subnet mask, default gateway, DNS server, and more. The address is leased for a set time. The client must renew before the lease expires, or the address goes back into the pool. DHCP uses UDP 67 (server) and UDP 68 (client).

StepMessageFromDelivery
DDHCPDISCOVERClientBroadcast. The client has no IP address and doesn't know any server. Source 0.0.0.0, destination 255.255.255.255.
ODHCPOFFERServerUnicast to the client's MAC: "here's an address you can have"
RDHCPREQUESTClientBroadcast. Accepts one offer, and tells any other servers their offers were declined.
ADHCPACKServerUnicast: the lease is confirmed and the client can use the address
Footnotes, and a preview In real captures, OFFER and ACK sometimes go to 255.255.255.255, depending on a "broadcast flag" the client sets. The exam answer is Discover and Request broadcast, Offer and Ack unicast. Configuring a DHCP server on a Cisco router, and ipconfig /release / /renew on a client, are CCNA 2 (SRWE) material.

Module 15 · 15.5

File sharing: FTP and SMB

Two ways to move files: grab a copy, or reach into the share as if it were local.

FTPSMB
ModelClient/server file transferClient/server request-response sharing
ConnectionsTwo: control on TCP 21 (commands and replies), data on TCP 20 (the file itself). A new data connection opens for each transfer.A long-term connection to the server
SharesFilesFiles, directories, printers, and serial ports, used as if they were local
PlatformsEverywhere. Plaintext, like HTTP.Native to Windows. Linux and UNIX use Samba; macOS supports SMB too.
Enrichment Port 20 for data is only true in FTP's active mode. Most clients use passive mode, where the server picks a random high port for data, so don't be surprised if your capture shows no port 20. SMB uses TCP 445, which NetAcad doesn't list.

Watch for this

Common Module 14–15 mistakes

These come up every semester.

Module Quiz — Network Application Communications

Checkpoint: Modules 14–15

This quiz opens Session 11. If you can do these cold, you're ready.

Study

Flashcards

Click to flip. Double-click to mark as known.

Check yourself

Sample questions

Pick an answer to see if you're right. Same style as the module quiz.

Applied

Worked examples

Think it through before you expand the answer.

SEQ / ACK

Real-looking numbers

PC-A picks ISN 5000 and SRV1 picks ISN 9000. Fill in the handshake. Then PC-A sends a 1,000-byte request. What acknowledgment number does SRV1 send back?

Show answer

SYN: SEQ 5000. SYN, ACK: SEQ 9000, ACK 5001. ACK: SEQ 5001, ACK 9001. The request also goes out with SEQ 5001, because the third handshake segment carried no data. SRV1 acknowledges with ACK 6001 (5001 + 1000).

MSS & loss

The middle segment goes missing

SRV1 sends a 4,380-byte file. MSS is 1460, and the first data byte is relative 1. How many segments are there, and what are their SEQs? The second segment is lost. What does PC-A ACK, and what does it ACK once the retransmission arrives?

Show answer

4380 ÷ 1460 = exactly 3 segments, with SEQs 1, 1461, 2921. After getting segments 1 and 3, PC-A can only ACK up to the gap: ACK 1461. Without SACK, SRV1 may re-send from 1461 onward. With SACK, PC-A also reports that it holds bytes 2921–4380, so only the missing segment is re-sent. Once it arrives, PC-A sends ACK 4381 (2921 + 1460).

Socket pairs

Two tabs and an SSH session

PC-A has two tabs open to http://www.it131.example and an SSH session to R1. Its source ports are 49712, 49713, and 49731. Write the three socket pairs. How does SRV1 tell the two tabs apart?

Show answer

192.168.10.10:49712 ↔ 192.168.20.100:80
192.168.10.10:49713 ↔ 192.168.20.100:80
192.168.10.10:49731 ↔ 192.168.10.1:22
The server side is identical for both tabs. SRV1 tells them apart by the client's source port.

TCP or UDP?

Pick the transport

A VoIP call. Downloading a 2 GB ISO over HTTPS. An ordinary DNS lookup. A zone transfer between DNS servers. Copying a config to a TFTP server. Getting an address by DHCP.

Show answer

VoIP: UDP (delay matters more than a lost packet). ISO over HTTPS: TCP 443 (every byte, in order). DNS lookup: UDP 53. Zone transfer: TCP 53. TFTP: UDP 69 (it does its own simple ACKs). DHCP: UDP 67/68.

netstat

"I think I have leftover connections"

A user runs netstat -an and sees:

PC-A
TCP 192.168.10.10:49712 192.168.20.100:443 ESTABLISHED TCP 192.168.10.10:49705 192.168.20.100:443 TIME_WAIT TCP 192.168.10.10:49706 192.168.20.100:443 TIME_WAIT UDP 0.0.0.0:123 *:*

Is anything wrong?

Show answer

Nothing is wrong. There's one live HTTPS session (ESTABLISHED, dynamic source port to well-known 443), and two recently closed sessions in TIME_WAIT that PC-A closed first. Those clear on their own. The UDP row has no state because UDP is connectionless.

DHCP

Name the DORA messages

PC-A boots, and R1 (192.168.10.1) is the DHCP server. Name each message:
1. 0.0.0.0 → 255.255.255.255, UDP 68 → 67
2. 192.168.10.1 → 192.168.10.10, UDP 67 → 68
3. 0.0.0.0 → 255.255.255.255, UDP 68 → 67
4. 192.168.10.1 → 192.168.10.10, UDP 67 → 68
Two days later PC-A renews its lease. What changes?

Show answer

1 DHCPDISCOVER (broadcast), 2 DHCPOFFER, 3 DHCPREQUEST (still broadcast, because the client doesn't have its address yet), 4 DHCPACK. At renewal PC-A already has 192.168.10.10 and knows the server, so its DHCPREQUEST is unicast from 192.168.10.10 to 192.168.10.1, and R1 answers with a DHCPACK.

Email

Phone and laptop

Which protocol carries a message from the sender's client to its mail server? A user reads mail on a phone and a laptop; which retrieval protocol leaves the laptop with the only copy, and which keeps both in sync?

Show answer

Sending: SMTP, TCP 25. Only copy on the laptop: POP3 (TCP 110), which downloads and deletes in NetAcad's model. In sync: IMAP (TCP 143), which keeps mail on the server.

Reference

Glossary & index

Every term from this session, searchable and indexed A–Z.