Chapterبەش 6 · Lectureوانە 6.1
TCP and UDPTCP و UDP
The transport layer's two protocols compared: TCP's reliable, ordered connection and UDP's light, connectionless datagrams; their headers, the checksum both carry, QUIC and HTTP/3 over UDP, DNS over both, VPN tunnels and LAN discovery over UDP, and which applications use which.
بەراوردی دوو : پەیوەندیی متمانەپێکراو و بە ڕیزی و سووک و ؛ سەردێڕەکانیان، ئەو هەردووکیان هەڵیدەگرن، و HTTP/3 بە سەر ، بە سەر هەردووکیاندا، تونێلەکانی و دۆزینەوە لە بە سەر و کام کامیان بەکار دەهێنێت.
What you will learnچی فێر دەبیت
- Explain what TCP and UDP both do and what only TCP adds.
- Compare their headers (20–60 bytes and 8 bytes) and name the fields.
- Compute and check a one's-complement checksum.
- Choose TCP or UDP for an application; explain QUIC, HTTP/3 and DNS over both, and why VPN tunnels and LAN discovery use UDP.
- ڕوونی بکەیتەوە و هەردووکیان چی دەکەن و چی تەنیا زیادی دەکات.
- سەردێڕەکانیان (20–60 و 8 ) بەراورد بکەیت و خانەکانیان ناو ببەیت.
- بژمێریت و بیپشکنیت.
- یان بۆ هەڵبژێریت؛ ، HTTP/3 و بە سەر هەردووکیاندا ڕوون بکەیتەوە، هەروەها بۆچی تونێلەکانی و دۆزینەوە لە بەکار دەهێنن.
Two delivery services: TCP and UDPدوو خزمەتگوزاریی گەیاندن: TCP و UDP
In OSI layers 4 and 5 you met the transport layer: it carries data from a program on one host to a program on another. TCP/IP gives this layer two protocols, and every application uses one of them: TCP, the Transmission Control Protocol, and UDP, the User Datagram Protocol. This lesson compares them: what each one promises, their headers, the checksum both of them carry, and which applications use which.
لە چینەکانی 4 و 5ی OSI ناسی: لە بەرنامەیەکەوە لەسەر بۆ بەرنامەیەک لەسەر تر دەگوازێتەوە. دوو بەم چینە دەدات و هەموو یەکێکیان بەکار دەهێنێت: (Transmission Control Protocol) و (User Datagram Protocol). ئەم وانەیە بەراوردیان دەکات: هەریەکەیان چ بەڵێنێک دەدات، سەردێڕەکانیان، ئەو هەردووکیان هەڵیدەگرن و کام کامیان بەکار دەهێنێت.
Send a registered letter and the post office records it, the receiver signs for it, and if it goes missing they search and send it again: that is TCP. Drop a postcard in the box and it simply goes; nobody tells you whether it arrived: that is UDP. Postcards are cheaper and quicker because nobody checks anything.
نامەیەکی تۆمارکراو بنێرە: پۆستخانە تۆماری دەکات، وەرگر واژۆی بۆ دەکات و ئەگەر ون بوو بەدوایدا دەگەڕێن و دووپاتە دەینێرنەوە: ئەمە . کارتپۆستاڵێک بخەرە سندووقەکەوە و هەر دەڕوات؛ کەس پێت ناڵێت گەیشت یان نا: ئەمە . کارتپۆستاڵ هەرزانتر و خێراترە چونکە کەس هیچ شتێک ناپشکنێت.
Where the analogy stops workingسنووری ئەم نموونەیە
A letter is not cut into numbered pieces, and the post office does not slow down when the roads are full; TCP does both. And a UDP datagram is not lost on purpose: it is lost only when a network is overloaded or broken.
نامە ناکرێتە پارچەی ژمارەدار و پۆستخانە کاتێک ڕێگاکان قەرەباڵغن خاو نابێتەوە؛ هەردووکیان دەکات. بە ئەنقەست ون نابێت: تەنیا کاتێک زۆر قەرەباڵغ یان تێکچوو بێت ون دەبێت.
What both do, and what only TCP addsئەوەی هەردووکیان دەیکەن و ئەوەی تەنیا TCP زیادی دەکات
Some sources call the transport layer “the heart of OSI”: everything above it depends on how well it moves the data. TCP and UDP both do three basic jobs. They multiplex: port numbers say which program each piece belongs to. They segment: the application's data is cut into pieces and every piece gets a header. And they detect errors with a checksum. TCP adds much more: it opens a connection, numbers the bytes, acknowledges what arrived, resends what was lost, delivers in order, controls the flow and the congestion, and finally closes the connection.
هەندێک سەرچاوە بە «دڵی OSI» ناو دەبەن: هەموو ئەوەی لە سەرویەتی پشت بەوە دەبەستێت کە چەند باش دەگوازێتەوە. و هەردووکیان سێ کاری بنەڕەتی دەکەن. دەکەن: ژمارەی دەڵێت هەر پارچەیەک هی کام بەرنامەیە. دەکەن: دەکرێتە پارچە و هەر پارچەیەک سەردێڕێک وەردەگرێت. هەروەها بە هەڵە دەدۆزنەوە. زۆر شتی تر زیاد دەکات: پەیوەندییەک دەکاتەوە، ژمارە دەکات، دان بەوەدا دەنێت کە گەیشتووە، ونبووەکان دووپاتە دەنێرێتەوە، بە ڕیز دەیانگەیەنێت، ڕەوت و قەرەباڵغی کۆنترۆڵ دەکات و لە کۆتاییدا پەیوەندییەکە دادەخات.
How TCP opens, manages and closes a connection is the subject of Inside a TCP connection; port numbers are in Port numbers and sockets.
چۆن پەیوەندییەک دەکاتەوە، بەڕێوەی دەبات و دایدەخات، بابەتی ناو پەیوەندییەکی TCPـە؛ ژمارەی لە وانەی ژمارەی پۆرت و سۆکێتەکان باس کراون.
What both do, and what only TCP addsئەوەی هەردووکیان دەیکەن و ئەوەی تەنیا TCP زیادی دەکات
How big is one segment?بڕێک چەند گەورەیە؟
Segmentation lets a host send a file of any size over any network: the transport layer decides how much data goes into each piece. On Ethernet a frame carries at most 1,500 bytes of payload (the MTU); the IP header and the TCP header take 20 bytes each, so one TCP segment carries up to 1,460 bytes of data. This number is the maximum segment size (MSS), and the two hosts tell each other theirs when the connection opens. The size depends on the link, not on the speed: a faster line sends the same segments in less time.
وا دەکات بتوانێت بە هەر قەبارەیەک بە سەر هەر بنێرێت: بڕیار دەدات چەند بچێتە ناو هەر پارچەیەکەوە. لەسەر Ethernet ئەوپەڕی 1,500 هەڵدەگرێت ()؛ سەردێڕی و سەردێڕی هەریەکەیان 20 دەگرن، بۆیە تا 1,460 هەڵدەگرێت. ئەم ژمارەیە گەورەترین قەبارەی (MSS)ـە و دوو لە کاتی کردنەوەی پەیوەندیدا هی خۆیان بە یەکتر دەڵێن. قەبارەکە بەندە بە بەستەرەکە، نەک بە خێرایی: هێڵێکی خێراتر هەمان لە کاتێکی کەمتردا دەنێرێت.
A 100-megabit file needs 8,561 full segments and one last segment of 940 bytes. At 1 Mbit/s it takes at least 100 seconds, at 100 Mbit/s about one second — with exactly the same segments.
100 Mbit پێویستی بە 8,561 پڕ و دوایین بە 940 هەیە. بە 1 Mbit/s لانیکەم 100 چرکەی دەوێت، بە 100 Mbit/s نزیکەی یەک چرکە — بە ڕێک هەمان .
The pieces of one message may travel by different routes and arrive out of order; the receiving transport layer puts them back together. That is reassembly — OSI layers 4 and 5 shows it as an animation.
پارچەکانی یەک نامە ڕەنگە بە ڕێگای جیاوازدا بڕۆن و بە ڕیزی جیاواز بگەن؛ وەرگر دووپاتە پێکەوەیان دەنێتەوە. ئەمە کۆکردنەوەیە — چینەکانی 4 و 5ی OSI بە ئەنیمەیشن پیشانی دەدات.
Different applications, different needsئەپەکانی جیاواز، پێویستیی جیاواز
Why two protocols? Because applications need different things. A voice call or a live video needs speed and little overhead: no waiting for acknowledgements and no resending, because a piece that arrives late is useless — deliver each piece as it arrives. E-mail, web pages and file downloads need the opposite: every byte acknowledged, lost data sent again, everything in the order it was sent. The application developer picks the transport protocol that fits the application; the user never chooses.
بۆچی دوو ؟ چونکە پێویستییان بە شتی جیاوازە. پەیوەندییەکی دەنگی یان ڤیدیۆیەکی ڕاستەوخۆ پێویستی بە خێرایی و بارگرانیی کەمە: چاوەڕێی نەکات و هیچ دووپاتە نەنێرێتەوە، چونکە پارچەیەک کە درەنگ بگات بێسوودە — هەر پارچەیەک هەرکاتێک گەیشت بیگەیەنە. ، و پێچەوانەکەیان دەوێت: دان بە هەموو بنرێت، ونبوو دووپاتە بنێردرێتەوە و هەموو شتێک بە ڕیزی ناردن بگات. گەشەپێدەری ئەو گواستنەوەیە هەڵدەبژێرێت کە لەگەڵ دەگونجێت؛ بەکارهێنەر هەرگیز هەڵی نابژێرێت.
TCP: connection-oriented and reliableTCP: گرێدانتەوەر و متمانەپێکراو
TCP is connection-oriented: before any data moves, the two hosts set up a connection with the three-way handshake, and everything TCP does is built around that connection — the way Java is called object-oriented because everything is built around objects. TCP, which almost every system has, then does its best to deliver every byte, without errors and in order. A TCP connection is full duplex: once it is open, both sides can send at the same time, like two friends typing in the same chat. Web browsing up to HTTP/2, e-mail (SMTP, IMAP, POP3), FTP, SSH and speed-test sites — which open several TCP connections at once — all use TCP.
: پێش ئەوەی هیچ بجووڵێت، دوو بە پەیوەندییەک دادەمەزرێنن و هەموو کارێکی لە دەوری ئەو پەیوەندییە دروست کراوە — وەک چۆن بە جاڤا دەڵێن ئۆبجێکتتەوەر، چونکە هەموو شتێکی لە دەوری ئۆبجێکت دروست کراوە. پاشان ، کە لە نزیکەی هەموو سیستەمێکدا هەیە، هەموو هەوڵێک دەدات هەموو بێ هەڵە و بە ڕیز بگەیەنێت. پەیوەندیی : کە کرایەوە، هەردوو لا دەتوانن لە هەمان کاتدا بنێرن، وەک دوو هاوڕێ کە لە هەمان چاتدا پێکەوە دەنووسن. گەڕان لە وێب تا HTTP/2، (، ، )، ، و ماڵپەڕەکانی پشکنینی خێرایی — کە لە یەک کاتدا چەند پەیوەندییەکی دەکەنەوە — هەموویان بەکار دەهێنن.
UDP: connectionless and lightUDP: بێگرێدان و سووک
UDP is connectionless: there is no handshake and no connection. Each datagram is sent on its own and handled independently, like a postcard. UDP adds very little to IP — ports, a length and a checksum — so its header is only 8 bytes and nothing waits or is resent. That makes UDP unreliable in the technical sense: it does not guarantee delivery or order. It does not make the application unreliable. A DNS client simply asks again when no answer comes, and a call or a game can live with a missing piece. Key users of UDP: DNS, DHCP, SNMP, TFTP, RIP, voice and video calls (RTP), online games — and, since HTTP/3, much web traffic.
: نە هەیە و نە پەیوەندی. هەر بە تەنیا دەنێردرێت و بە سەربەخۆیی مامەڵەی لەگەڵ دەکرێت، وەک کارتپۆستاڵێک. شتێکی زۆر کەم بۆ زیاد دەکات — ، درێژی و — بۆیە سەردێڕەکەی تەنیا 8 و هیچ شتێک چاوەڕێ ناکات یان دووپاتە نانێردرێتەوە. ئەمە بە واتا تەکنیکییەکەی نامتمانەپێکراو دەکات: گەیاندن و ڕیز مسۆگەر ناکات. بەڵام نامتمانەپێکراو ناکات. کاتێک وەڵام نایەت تەنیا دووپاتە دەپرسێتەوە و پەیوەندییەکی دەنگی یان یارییەک دەتوانێت لەگەڵ پارچەیەکی ونبوودا بژی. بەکارهێنەرە سەرەکییەکانی : ، ، SNMP، ، ، پەیوەندیی دەنگی و ڤیدیۆیی (RTP)، یاریی ئۆنلاین — و لە HTTP/3ـەوە بەشێکی زۆری هاتوچۆی وێب.
When a piece is lostکاتێک پارچەیەک ون دەبێت
Here is the real difference. A server sends Aram a PDF with TCP while Shilan makes a video call from Erbil to Duhok over UDP. On both roads piece 3 is lost. TCP's receiver keeps pieces 4 and 5 in its buffer and asks for 3 again; the sender resends it, and the file is complete and in order — a little later. The video call cannot wait: the app shows what it has, the picture glitches for a moment, and the call goes on with pieces 6 and 7.
جیاوازییە ڕاستەقینەکە ئەمەیە. بە PDFێک بۆ ئارام دەنێرێت، لە کاتێکدا شیلان بە پەیوەندییەکی ڤیدیۆیی لە هەولێرەوە بۆ دهۆک دەکات. لە هەردوو ڕێگاکەدا پارچەی 3 ون دەبێت. وەرگری پارچەکانی 4 و 5 لە دەهێڵێتەوە و دووپاتە داوای 3 دەکات؛ نێرەر دووپاتەی دەنێرێتەوە و تەواو و بە ڕیز دەگات — کەمێک دواتر. پەیوەندییە ڤیدیۆییەکە ناتوانێت چاوەڕێ بکات: ئەوەی هەیەتی پیشانی دەدات، وێنەکە ساتێک دەپچڕێت و پەیوەندییەکە بە پارچەکانی 6 و 7 بەردەوام دەبێت.


TCP is not “slow”: on a good network it is very fast. It waits only for the handshake at the start and when something is lost.
«خاو» نییە: لەسەر باش زۆر خێرایە. تەنیا بۆ لە سەرەتادا و کاتێک شتێک ون دەبێت چاوەڕێ دەکات.
Two headers: 20 bytes and 8 bytesدوو سەردێڕ: 20 بایت و 8 بایت
Every segment and every datagram starts with a header. Both headers begin with the source port and the destination port, 16 bits each, and both carry a 16-bit checksum. The UDP header adds only a length field: 8 bytes in all. The TCP header is at least 20 bytes: it also carries the sequence number, the acknowledgement number, the header length (data offset), the flags, the window and the urgent pointer. Options can make it up to 60 bytes, because the data offset counts the header in 4-byte words, from 5 (20 bytes) to 15 (60 bytes).
هەموو و هەموو بە سەردێڕێک دەست پێ دەکات. هەردوو سەردێڕەکە بە سەرچاوە و مەبەست دەست پێ دەکەن، هەریەکەیان 16 . هەروەها هەردووکیان 16 هەڵدەگرن. سەردێڕی تەنیا خانەیەکی درێژی زیاد دەکات: سەرجەم 8 . سەردێڕی لانیکەم 20 : ، ژمارەی ، درێژیی سەردێڕ (data offset)، ئاڵاکان، و نیشاندەری بەپەلەش هەڵدەگرێت. هەڵبژاردەکان دەتوانن بیکەنە تا 60 ، چونکە data offset سەردێڕەکە بە وشەی 4 دەژمێرێت، لە 5 وشە (20 ) تا 15 وشە (60 ).
Two headers: 20 bytes and 8 bytesدوو سەردێڕ: 20 بایت و 8 بایت
What each TCP field is forهەر خانەیەکی TCP بۆ چییە
| Fieldخانە | Sizeقەبارە | What it is forبۆ چییە |
|---|---|---|
| Source port سەرچاوە | 16 bit | The sending programبەرنامەی نێرەر |
| Destination port مەبەست | 16 bit | The receiving programبەرنامەی وەرگر |
| Sequence number | 32 bit | The number of the first data byte in this segmentژمارەی یەکەم لەم |
| Acknowledgement numberژمارەی | 32 bit | The next byte this side expects from the other side (valid when ACK is set) داهاتوو کە ئەم لایە چاوەڕێی دەکات (کاتێک ACK دانرابێت) |
| Data offsetData offset (درێژیی سەردێڕ) | 4 bit | Header length in 4-byte words: 5 to 15درێژیی سەردێڕ بە وشەی 4 : 5 تا 15 |
| Reservedپارێزراو | 4 bit | Kept for the future; sent as 0بۆ داهاتوو هەڵگیراوە؛ وەک 0 دەنێردرێت |
| Flagsئاڵاکان | 8 × 1 bit | CWR and ECE (congestion signals), URG, ACK, PSH, RST, SYN, FIN — see control bitsCWR و ECE (ئاماژەی قەرەباڵغی)، URG، ACK، PSH، RST، SYN، FIN — بڕوانە بیتەکانی کۆنترۆڵ |
| Window (window size) | 16 bit | How many bytes the receiver can take nowوەرگر ئێستا چەند وەردەگرێت |
| Checksum | 16 bit | Error detection over the header, the data and the IP addressesدۆزینەوەی هەڵە لە سەردێڕ، و |
| Urgent pointerنیشاندەری بەپەلە | 16 bit | Marks urgent data; rarely used today بەپەلە دیاری دەکات؛ ئەمڕۆ کەم بەکار دێت |
| Optionsهەڵبژاردەکان | 0–40 bytes0–40 | For example the MSS, window scaling and timestampsبۆ نموونە MSS، گەورەکردنی و |
Segment, datagram, packet: the right wordsبڕ، داتاگرام، پاکێت: وشە دروستەکان
Each layer has its own name for its unit of data. TCP's unit is a segment; UDP's unit is a datagram; the IP layer puts either of them inside a packet; and the link layer puts the packet inside a frame. You will sometimes read “packet” for TCP data and “datagram” for UDP data, with the idea that a datagram is a piece with no guarantee. Keep the exact words: segment (TCP), datagram (UDP), packet (IP). The full ladder of names is in PDUs.
هەر چینێک ناوێکی تایبەتی بۆ یەکەی خۆی هەیە. یەکەی ؛ یەکەی ؛ چینی هەر کامیان بێت دەیخاتە ناو ؛ و چینی بەستەر دەخاتە ناو . هەندێک جار دەخوێنیتەوە کە «» بۆ و «» بۆ بەکار دێت، بەو بیرۆکەیەی کە پارچەیەکی بێ گەرەنتییە. وشە ورددەکان بەکار بهێنە: ()، ()، (). هەموو پەیژەی ناوەکان لە یەکەکانی دراوەی پرۆتۆکۆڵدایە.
Both TCP and UDP carry a checksumTCP و UDP هەردووکیان پشکنینی کۆ هەڵدەگرن
A checksum is a short number computed from the data. The sender puts it in the header; the receiver computes it again, and a different result means the segment was damaged on the way. TCP and UDP both use the Internet checksum, a one's-complement sum — one's complement is taught in Logic Design. Here it is with tiny 4-bit words: add the words; if a carry comes out of the top bit, wrap it around and add it at the bottom; then flip every bit. The receiver adds all the words and the checksum: all 1s means no error was found.
ژمارەیەکی کورتە کە لە دەژمێردرێت. نێرەر دەیخاتە ناو سەردێڕەکەوە؛ وەرگر دووپاتە دەیژمێرێتەوە و ئەنجامێکی جیاواز واتای ئەوەیە کە لە ڕێگادا تێکچووە. و هەردووکیان ئینتەرنێت بەکار دەهێنن، کە کۆکردنەوەیەکە بە — تەواوکەری یەک لە دیزاینی دەخوێندرێت. لێرەدا بە وشەی بچووکی 4 نیشان دراوە: وشەکان کۆ بکەرەوە؛ ئەگەر لە سەرووترین زیادی کرد، بیگەڕێنەوە و لە خوارەوە زیادی بکە؛ پاشان هەموو پێچەوانە بکەرەوە. وەرگر هەموو وشەکان و کۆ دەکاتەوە: ئەگەر هەمووی 1 بوو، هیچ هەڵەیەک نەدۆزراوەتەوە.
The checksum worked through with binary words: add them, wrap the carry around and flip the bits; the receiver adds everything and checks for all 1s.
بە نموونەی وشەی : وشەکان کۆ بکەرەوە، زیادەی سەرەوە بگەڕێنەوە بۆ خوارەوە و هەموو پێچەوانە بکەرەوە؛ وەرگر هەموویان کۆ دەکاتەوە و سەیر دەکات کە هەمووی 1 بێت.
Whole video: the sender's and the receiver's side of the one's-complement checksum, with a worked example.
هەموو ڤیدیۆکە: لای نێرەر و لای وەرگری بە ، لەگەڵ نموونەیەکی چارەسەرکراو.
Both TCP and UDP carry a checksumTCP و UDP هەردووکیان پشکنینی کۆ هەڵدەگرن
The real thing: 16-bit wordsشتە ڕاستەقینەکە: وشەی 16 بیتی
Real checksums use 16-bit words (RFC 1071). This Python program computes the checksum of the 8 bytes that RFC 1071 uses as its example, checks it the way a receiver does, and then changes one bit.
ڕاستەقینە وشەی 16 بەکار دەهێنن (RFC 1071). ئەم بەرنامە Pythonـە ئەو 8 دەژمێرێت کە RFC 1071 وەک نموونە بەکاریان دەهێنێت، وەک وەرگرێک دەیپشکنێت و پاشان یەک دەگۆڕێت.
def ones_complement_sum(data):
total = 0
for i in range(0, len(data), 2):
word = (data[i] << 8) + data[i + 1] # two bytes -> one 16-bit word
total += word
total = (total & 0xFFFF) + (total >> 16) # wrap the carry around
return total
data = bytes([0x00, 0x01, 0xF2, 0x03, 0xF4, 0xF5, 0xF6, 0xF7])
s = ones_complement_sum(data)
checksum = ~s & 0xFFFF # flip every bit
print(f"sum = {s:04x}")
print(f"checksum = {checksum:04x}")
# The receiver adds the same words AND the checksum:
received = data + checksum.to_bytes(2, "big")
print(f"receiver = {ones_complement_sum(received):04x}") # ffff = no error found
damaged = bytes([0x00, 0x01, 0xF2, 0x13]) + received[4:] # one bit changed
print(f"damaged = {ones_complement_sum(damaged):04x}")sum = ddf2 checksum = 220d receiver = ffff damaged = 0010
Explain the codeڕوونکردنەوەی کۆدەکە
- Lineدێڕی 6
Wrap-around: any carry above 16 bits is added back at the bottom.
گەڕاندنەوە: هەر لە سەرووی 16 زیاد بێت لە خوارەوە دەخرێتەوە سەری.
- Lineدێڕی 11
~s & 0xFFFFflips all 16 bits: the one's complement.~s & 0xFFFFهەموو 16 پێچەوانە دەکاتەوە: .- Lineدێڕی 17
The receiver's sum including the checksum is
ffff(all 1s): no error found.کۆی وەرگر لەگەڵ
ffffـە (هەمووی 1): هیچ هەڵەیەک نەدۆزرایەوە.
The checksum covers the header, the data and a pseudo-header with the two IP addresses, so a segment delivered to the wrong host is caught too. A damaged segment or datagram is simply thrown away: TCP notices the missing bytes and resends them, UDP does nothing. In UDP over IPv4 an all-zero checksum means the sender did not compute one (over IPv6 the UDP checksum is required); TCP's checksum is never optional. It catches accidents, not attackers — protection against deliberate changes comes from TLS.
سەردێڕ، و سەردێڕێکی ساختە دەگرێتەوە کە دوو تێدایە، بۆیە کە بۆ هەڵە بگات ئەویش دەدۆزرێتەوە. یان تێکچوو تەنیا فڕێ دەدرێت: ونبوو دەبینێت و دووپاتەیان دەنێرێتەوە، هیچ ناکات. لە بە سەر ، سفر واتای ئەوەیە کە نێرەر هیچی نەژماردووە (بە سەر ناچارییە)؛ هەرگیز ئارەزوومەندانە نییە. ڕووداوی ڕێکەوت دەگرێت، نەک — پاراستن لە گۆڕینی ئەنقەست لە TLSـەوە دێت.
QUIC and HTTP/3: reliable, but over UDPQUIC و HTTP/3: متمانەپێکراو، بەڵام بە سەر UDPـدا
Today a large part of web traffic does not use TCP at all. HTTP/3 (RFC 9114, 2022) runs over QUIC (RFC 9000, 2021), and QUIC runs over UDP, normally on UDP port 443. QUIC does TCP's jobs itself: it sets up a connection, numbers its packets, acknowledges them, resends what was lost and controls the flow and the congestion. It also always encrypts with TLS 1.3. Why build it on UDP instead of making a new protocol next to TCP? Many firewalls and home routers on the Internet pass only TCP and UDP, and QUIC lives inside the application, so a browser update can improve it.
ئەمڕۆ بەشێکی گەورەی هاتوچۆی وێب هەر بەکار ناهێنێت. HTTP/3 (RFC 9114، 2022) بە سەر (RFC 9000، 2021)دا کار دەکات و بە سەر ، ئاسایی لەسەر 443ی . کارەکانی خۆی دەکات: پەیوەندی دادەمەزرێنێت، ژمارە دەکات، دانیان پێدا دەنێت، ونبووەکان دووپاتە دەنێرێتەوە و ڕەوت و قەرەباڵغی کۆنترۆڵ دەکات. هەروەها هەمیشە بە TLS 1.3 دەکات. بۆچی لە سەر دروست کرا، نەک نوێ لە تەنیشت ؟ زۆرێک لە و ماڵەوە لە تەنیا و تێدەپەڕێنن و لە ناو دەژی، بۆیە نوێکردنەوەیەکی دەتوانێت باشتری بکات.
So “UDP is unreliable” describes UDP itself, not what is built on it: QUIC gives the web a fully reliable, encrypted transport on top of UDP. When a network blocks UDP port 443, the browser simply falls back to HTTP/2 over TCP. HTTP itself is in HTTP and the request cycle, its three versions are compared in HTTP/1.1, HTTP/2 and HTTP/3, and where TLS sits is in OSI layers 6 and 7.
کەواتە « نامتمانەپێکراوە» باسی خودی دەکات، نەک ئەوەی لە سەری دروست دەکرێت: گواستنەوەیەکی تەواو متمانەپێکراو و پارێزراو بە لە سەر دەداتە وێب. کاتێک ڕێگە لە 443ی دەگرێت، بە ئاسانی دەگەڕێتەوە بۆ HTTP/2 بە سەر . خودی لە HTTP و خولی داواکاری باس کراوە، سێ وەشانەکەی لە HTTP/1.1، HTTP/2 و HTTP/3 بەراورد کراون و شوێنی لە چینەکانی 6 و 7ی OSI.
DNS uses bothDNS هەردووکیان بەکار دەهێنێت
Microsoft's documentation, like the DNS standards, says that DNS works over both TCP and UDP, on port 53. A normal question (“what is the address of www.example.com?”) and its answer each fit in one small UDP datagram: no handshake, so the answer comes quickly. If the answer is too big for the UDP message, the server sends a shortened answer with the TC (truncated) flag set, and the client asks the same question again over TCP. Copying a whole zone from one DNS server to another (a zone transfer) always uses TCP. Since RFC 7766 (2016) every general-purpose DNS program must support both.
بەڵگەنامەکانی Microsoft، وەک ستانداردەکانی ، دەڵێن بە سەر هەردوو و کار دەکات، لەسەر 53. پرسیارێکی ئاسایی («ناونیشانی www.example.com چییە؟») و وەڵامەکەی هەریەکەیان لە یەک بچووکی جێیان دەبێتەوە: بێ ، بۆیە وەڵامەکە خێرا دێت. ئەگەر وەڵامەکە بۆ نامەی زۆر گەورە بێت، وەڵامێکی کورتکراوە دەنێرێت و ئاڵای TC (truncated) دادەنێت و هەمان پرسیار دووپاتە بە دەکاتەوە. کۆپیکردنی هەموو ناوچەیەک لە بۆ یەکێکی تر (zone transfer) هەمیشە بەکار دەهێنێت. لە RFC 7766ـەوە (2016) هەموو بەرنامەیەکی گشتیی دەبێت پشتگیریی هەردووکیان بکات.
VPN tunnels ride on UDPتونێلەکانی VPN بە سەر UDPـدا دەڕۆن
A VPN builds an encrypted tunnel across the Internet. Your laptop puts each of its packets — often the TCP segments of a web page — inside the VPN's own encrypted packets, and most VPNs send those as UDP datagrams. WireGuard uses only UDP; OpenVPN uses UDP port 1194 unless you choose TCP; and IPsec VPNs that pass through a home router use UDP port 4500. What a VPN is for is explained in VPNs.
تونێلێکی شفرەکراو بە ناو دروست دەکات. هەر خۆی — زۆر جار — دەخاتە ناو شفرەکراوەکانی خودی و زۆربەی ئەو وەک دەنێرن. WireGuard تەنیا بەکار دەهێنێت؛ OpenVPN 1194ی بەکار دەهێنێت مەگەر خۆت هەڵبژێریت؛ IPsecـیش، کاتێک بە ماڵەوەدا تێدەپەڕێت، 4500ی بەکار دەهێنێت. بۆ چییە لە VPNـەکاندا ڕوون کراوەتەوە.
Why UDP? Because losing a piece of the tunnel does no harm: the protocol inside takes care of it. If a datagram is lost, nothing in the tunnel resends it; the TCP connection inside sees the gap and resends the missing segment itself, end to end. A tunnel over TCP would resend the same loss twice — the outer TCP and the inner TCP, each with its own timers — and everything in the tunnel would wait. For this reason WireGuard does not offer TCP at all.
بۆچی ؟ چونکە ونبوونی پارچەیەکی تونێلەکە زیانی نییە: ناوەوە چارەسەری دەکات. ئەگەر ون بێت، هیچ شتێکی ناو تونێلەکە دووپاتە ناینێرێتەوە؛ پەیوەندیی ناوەوە کەلێنەکە دەبینێت و خۆی ونبووەکە لە سەرێکەوە بۆ سەرەکەی تر دووپاتە دەنێرێتەوە. تونێلێک بە سەر هەمان ونبوون دوو جار دەنێرێتەوە — دەرەوە و ناوەوە، هەریەکەیان بە خۆی — و هەموو شتێکی ناو تونێلەکە چاوەڕێ دەکات. بۆیە WireGuard هەر پێشکەش ناکات.
Finding each other on a LAN: only UDP can ask everyoneدۆزینەوەی یەکتر لە ڕایەڵەی ناوچەییدا: تەنیا UDP دەتوانێت لە هەمووان بپرسێت
How does your phone find the smart TV, the printer or a friend's game on the same Wi-Fi before it knows their addresses? It sends one small question to every device on the LAN — a broadcast, or a multicast to a group address (unicast, broadcast and multicast) — and only the devices that match answer. This needs UDP: a TCP connection always joins exactly two programs, so TCP cannot send one segment to many receivers.
مۆبایلەکەت چۆن ، یان یارییەکی هاوڕێکەت لەسەر هەمان دەدۆزێتەوە، پێش ئەوەی ناونیشانەکانیان بزانێت؟ یەک پرسیاری بچووک بۆ هەموو ئامێرێکی ناو دەنێرێت — ، یان بۆ ناونیشانێکی گرووپ (تاکپەخش، پەخشکردن و فرەپەخش) — و تەنیا ئەو ئامێرانە وەڵام دەدەنەوە کە لەگەڵ پرسیارەکە دەگونجێن. ئەمە پێویستی بە : پەیوەندییەکی هەمیشە ڕێک دوو بەرنامە بە یەکەوە دەبەستێتەوە، بۆیە ناتوانێت یەک بۆ چەند وەرگرێک بنێرێت.


You use such discovery every day. A new laptop's first DHCP message is a broadcast to UDP port 67 (DORA). Printers, smart TVs and phones find each other's names with mDNS on UDP port 5353 (peer names). UPnP devices announce themselves with SSDP on UDP port 1900, and LAN games broadcast “a game is open here”. After the discovery, the real conversation usually moves to an ordinary TCP connection between the two devices.
ڕۆژانە ئەم جۆرە دۆزینەوەیە بەکار دەهێنیت. یەکەم پەیامی نوێ بۆ 67ی (DORA). ، و مۆبایلەکان بە mDNS لەسەر 5353ی ناوی یەکتر دەدۆزنەوە (ناوی تاکەکان). ئامێرەکانی UPnP بە SSDP لەسەر 1900ی خۆیان ڕادەگەیەنن و یارییەکانی بە ڕادەگەیەنن کە «لێرە یارییەک کراوەیە». دوای دۆزینەوەکە، گفتوگۆ ڕاستەقینەکە زۆربەی جار دەچێتە سەر پەیوەندییەکی ئاسایی لە نێوان دوو ئامێرەکەدا.
Which protocol for which application?کام پرۆتۆکۆڵ بۆ کام ئەپ؟
| Featureتایبەتمەندی | TCP | UDP |
|---|---|---|
| Deliveryگەیاندن | Reliable: every byte or an errorمتمانەپێکراو: هەموو یان هەڵە | Best effort: no guaranteeباشترین هەوڵ: بێ گەرەنتی |
| Connection set-upدامەزراندنی پەیوەندی | Yes, three-way handshakeبەڵێ، | Noنەخێر |
| Error detection (checksum)دۆزینەوەی هەڵە () | Yesبەڵێ | Yesبەڵێ |
| Resending lost data ونبوو | Yesبەڵێ | Noنەخێر |
| Ordered deliveryگەیاندن بە ڕیز | Yesبەڵێ | Noنەخێر |
| Flow control | Yes (window)بەڵێ () | Noنەخێر |
| Congestion control | Yesبەڵێ | Noنەخێر |
| Headerسەردێڕ | 20–60 bytes20–60 | 8 bytes8 |
| Unit of dataیەکەی | Segment | Datagram |
| Typical usesبەکارهێنانی باو | Web (HTTP/1.1, HTTP/2), e-mail (SMTP, IMAP, POP3), FTP, SSH, chat text, MQTTوێب (HTTP/1.1، HTTP/2)، (، ، )، ، ، نووسینی چات، | DNS questions, DHCP, voice and video calls (RTP), game moves, TFTP, SNMP, RIP, VPN tunnels (WireGuard), LAN discovery (mDNS, SSDP), QUIC/HTTP/3پرسیاری ، ، پەیوەندیی دەنگی و ڤیدیۆیی (RTP)، جووڵەی یاری، ، SNMP، ، تونێلی (WireGuard)، دۆزینەوە لە (mDNS، SSDP)، و HTTP/3 |
Some everyday examples. SMTP, which carries e-mail between servers, runs over TCP (port 25): a letter with missing words is no use. A speed-test website, like every site that uses HTTP, runs over TCP and opens several connections at once to fill the line. A YouTube video you watch — even a live one — comes over HTTP, today often HTTP/3 over QUIC, so no part of it is lost. Real-time calls are different: a WhatsApp, Messenger or Teams call sends its voice and video in UDP datagrams, and a lost piece is simply skipped. A game often uses both: UDP for the players' moves, TCP for logging in, chat and voice messages. In the Internet of Things, MQTT runs over TCP (see IoT data protocols).
چەند نموونەیەکی ڕۆژانە. ، کە لە نێوان دەگوازێتەوە، بە سەر دا کار دەکات ( 25): نامەیەک کە وشەی تێدا کەم بێت بێسوودە. ماڵپەڕێکی پشکنینی خێرایی، وەک هەموو ماڵپەڕێک کە بەکار دەهێنێت، بە سەر کار دەکات و لە یەک کاتدا چەند پەیوەندییەک دەکاتەوە تا هێڵەکە پڕ بکات. ڤیدیۆیەکی YouTube کە سەیری دەکەیت — تەنانەت ڕاستەوخۆش — بە دێت، ئەمڕۆ زۆر جار HTTP/3 بە سەر ، بۆیە هیچ بەشێکی ون نابێت. پەیوەندیی ڕاستەوخۆ جیاوازە: پەیوەندییەکی WhatsApp، Messenger یان Teams دەنگ و ڤیدیۆکەی لە دەنێرێت و پارچەی ونبوو تەنیا تێدەپەڕێنرێت. یارییەک زۆر جار هەردووکیان بەکار دەهێنێت: بۆ جووڵەی یاریزانەکان، بۆ چوونەژوورەوە، چات و نامەی دەنگی. لە ، بە سەر کار دەکات (بڕوانە پرۆتۆکۆڵەکانی دراوەی IoT).
A shorter list of protocols and layers is in data communication; the port number of each service is in port numbers and sockets.
لیستێکی کورتتری و چینەکان لە پەیوەندیی دراوەدایە؛ ژمارەی هەر خزمەتگوزارییەک لە وانەی ژمارەی پۆرت و سۆکێتەکان هەیە.
Common mistakesهەڵە باوەکان
Exercisesڕاهێنانەکان
Two main protocols that are examples of TCP/IP transport-layer protocols are ___ and ___.
دوو سەرەکی کە نموونەی ___ و ___ن.
Show answerوەڵامەکە پیشان بدە
TCP and UDP.
و .
For each application, say which transport protocol fits it and why: (a) uploading an assignment to the university's website; (b) a live voice call from Sulaimani to Erbil; (c) looking up the address of www.example.com; (d) managing a router from your laptop with SSH; (e) the players' moves in an online football game.
بۆ هەر بڵێ کام گواستنەوە لەگەڵیدا دەگونجێت و بۆچی: (a) ئەرکێک بۆ ماڵپەڕی زانکۆ؛ (b) پەیوەندییەکی دەنگیی ڕاستەوخۆ لە سلێمانییەوە بۆ هەولێر؛ (c) دۆزینەوەی ناونیشانی www.example.com؛ (d) بەڕێوەبردنی لە بە ؛ (e) جووڵەی یاریزانەکان لە یارییەکی تۆپی پێی ئۆنلایندا.
Show answerوەڵامەکە پیشان بدە
- (a) TCP: every byte of the file must arrive (HTTP over TCP, or HTTP/3 over QUIC, which is also reliable).
- (b) UDP: a late piece of voice is useless; a short gap is better than waiting.
- (c) UDP: one small question and one small answer on port 53; TCP only if the answer is truncated.
- (d) TCP: every command and every character must arrive, in order (SSH uses TCP port 22).
- (e) UDP: the newest position matters; an old one that arrives late is already out of date.
- (a) : هەموو دەبێت بگات ( بە سەر ، یان HTTP/3 بە سەر کە ئەویش متمانەپێکراوە).
- (b) : پارچە دەنگێکی دواکەوتوو بێسوودە؛ بۆشاییەکی کورت باشترە لە چاوەڕوانی.
- (c) : پرسیارێکی بچووک و وەڵامێکی بچووک لەسەر 53؛ تەنیا ئەگەر وەڵامەکە کورتکرابێتەوە.
- (d) : هەموو فەرمانێک و هەموو پیتێک دەبێت بە ڕیز بگات ( 22ی بەکار دەهێنێت).
- (e) : نوێترین شوێن گرنگە؛ شوێنێکی کۆن کە درەنگ بگات پێشتر کۆن بووە.
A sender has the two 4-bit words 1100 and 1010. Compute the checksum the way TCP and UDP do, then check it as the receiver.
نێرەرێک دوو وشەی 4 هەیە: 1100 و 1010. وەک و بژمێرە، پاشان وەک وەرگر بیپشکنە.
Hintئاماژە
Add, wrap any fifth bit back to the bottom, then flip every bit.
کۆ بکەرەوە، پێنجەم بگەڕێنەوە بۆ خوارەوە، پاشان هەموو پێچەوانە بکەرەوە.
Show answerوەڵامەکە پیشان بدە
The checksum is 1000. The receiver's sum is 1111 — all 1s, so no error was found.
1000ـە. کۆی وەرگر 1111ـە — هەمووی 1، کەواتە هیچ هەڵەیەک نەدۆزرایەوە.
A file of 2,920,000 bytes is sent over Ethernet with an MSS of 1,460 bytes. How many TCP segments carry it? Does the answer change on a faster line?
بە 2,920,000 بە سەر Ethernetـدا بە MSSی 1,460 دەنێردرێت. چەند هەڵیدەگرن؟ ئایا وەڵامەکە لەسەر هێڵێکی خێراتر دەگۆڕێت؟
Show answerوەڵامەکە پیشان بدە
2,920,000 ÷ 1,460 = 2,000 segments. No: a faster line sends the same 2,000 segments in less time.
2,920,000 ÷ 1,460 = 2,000 . نەخێر: هێڵێکی خێراتر هەمان 2,000 لە کاتێکی کەمتردا دەنێرێت.
Summaryپوختە
- TCP and UDP are TCP/IP's two transport protocols. Both use ports, cut data into pieces and carry a checksum.
- TCP (RFC 9293) is connection-oriented, reliable, ordered and full duplex, with flow and congestion control; header 20–60 bytes; its unit is the segment.
- UDP (RFC 768) is connectionless and light: no handshake, no resending, no order; header 8 bytes; its unit is the datagram.
- The checksum is a one's-complement sum: the receiver expects all 1s. It detects damage; only TCP recovers by resending.
- Downloads, web pages, e-mail (SMTP!) and SSH use TCP; calls, game moves, DNS questions and DHCP use UDP; HTTP/3 uses QUIC over UDP; DNS uses both.
- UDP also carries most VPN tunnels — the TCP inside resends what is lost — and discovery on a LAN, because only UDP can send to everyone (broadcast and multicast).
- و دوو گواستنەوەی . هەردووکیان بەکار دەهێنن، دەکەنە پارچە و هەڵدەگرن.
- (RFC 9293) ، متمانەپێکراو، بە ڕیز و ، بە و ؛ سەردێڕ 20–60 ؛ یەکەکەی .
- (RFC 768) و سووکە: بێ ، بێ ، بێ ڕیز؛ سەردێڕ 8 ؛ یەکەکەی .
- کۆکردنەوەیەکی : وەرگر چاوەڕێی هەمووی 1 دەکات. تێکچوون دەدۆزێتەوە؛ تەنیا بە چاکی دەکاتەوە.
- ، ، (!) و بەکار دەهێنن؛ پەیوەندی، جووڵەی یاری، پرسیاری و ؛ HTTP/3 بە سەر ؛ هەردووکیان.
- زۆربەی تونێلەکانی هەڵدەگرێت — ناوەوە ونبوو دووپاتە دەنێرێتەوە — هەروەها دۆزینەوە لە ، چونکە تەنیا دەتوانێت بۆ هەمووان بنێرێت ( و ).
Next: port numbers and sockets, then inside a TCP connection.
دواتر: ژمارەی پۆرت و سۆکێتەکان، پاشان ناو پەیوەندییەکی TCP.
Lesson complete!وانەکە تەواو بوو!
Well done. Review the key terms, then go on to the next lesson.دەستخۆش. سەیرێکی زاراوە سەرەکییەکان بکەرەوە، پاشان بڕۆ بۆ وانەی داهاتوو.
Key termsزاراوە سەرەکییەکان
Port Numbers and Socketsژمارەی پۆرت و سۆکێتەکان
Related lecturesوانە پەیوەندیدارەکان
- Port Numbers and Socketsژمارەی پۆرت و سۆکێتەکان
- Inside a TCP Connection: Handshake, Windows and Reliabilityناو پەیوەندییەکی TCP: سێ ڕێی تەوقەکردن، پەنجەرەکان و پشتپێبەستراوی
- The TCP/IP Model and How It Maps to OSIمۆدێلی TCP/IP و چۆنییەتیی یەکگرتنەوەی لەگەڵ OSI
- The Network Layer and the IPv4 Packetچینی ڕایەڵە و پاکێتی IPv4
- 1's and 2's Complementsتەواوکەری یەک و تەواوکەری دوو
- Sending IoT Data: HTTP, JSON and MQTTناردنی دراوەی IoT: HTTP، JSON و MQTT
- HTTP and the Request–Response CycleHTTP و سووڕی داواکاری و وەڵام
- Data Communication: Modes, Switching and Protocolsپەیوەندیی دراوە: شێوازەکانی ناردن، سویچکردن و پرۆتۆکۆڵەکان
References and further readingسەرچاوەکان و خوێندنەوەی زیاتر
- RFC 9293: Transmission Control Protocol (TCP), 2022
- RFC 768: User Datagram Protocol
- RFC 1071: Computing the Internet Checksum
- RFC 9000: QUIC, a UDP-based multiplexed and secure transport
- RFC 9114: HTTP/3
- RFC 7766: DNS Transport over TCP — Implementation Requirements
- DNS Flag Day 2020 (EDNS buffer size 1232 bytes)
- IANA Service Name and Transport Protocol Port Number Registry
- WireGuard: Known limitations (no TCP: TCP-over-TCP performs very badly)
- OpenVPN 2.6 manual (--proto: udp is the default; --port: 1194, the IANA port)
- RFC 3948: UDP Encapsulation of IPsec ESP Packets (UDP port 4500 for NAT traversal)
- RFC 6762: Multicast DNS (UDP port 5353, 224.0.0.251)
- Wikipedia: Simple Service Discovery Protocol (UDP port 1900, 239.255.255.250)
- Wikipedia: User Datagram Protocol (broadcast, multicast, service discovery, tunnelling, VPNs)
This lecture is a first edition. The Kurdish text and terminology are waiting for review by Kurdish IT teachers.ئەم وانەیە چاپی یەکەمە. دەقە کوردییەکە و زاراوەکانی چاوەڕێی پێداچوونەوەی مامۆستایانی کوردی بواری IT ن.