Networking · 6 min read · 30 November 2026
TCP vs UDP: Differences, Ports and When Each Protocol Is Used
TCP delivers every byte in order; UDP sends fast with no guarantees. How each works, which applications and ports use them, and what it means for firewalls.
TCP and UDP are the two main ways applications send data across an IP network. TCP (Transmission Control Protocol) guarantees that every byte arrives, in order; UDP (User Datagram Protocol) simply sends packets and does not wait for confirmation. TCP is chosen when accuracy matters more than speed, UDP when a late packet is worse than a lost one.
How TCP works
- Connection first: the two ends set up a session with a three-way handshake (SYN, SYN-ACK, ACK) before any data is sent.
- Reliable and ordered: every segment is numbered and acknowledged. Missing data is sent again and the receiver puts everything back in order.
- Flow and congestion control: TCP slows down when the receiver or the network cannot keep up.
- Cost: a header of at least 20 bytes and extra round trips, so it reacts more slowly on long or lossy links.
How UDP works
- No connection: the sender just transmits datagrams.
- No delivery guarantee: lost or out-of-order packets are not fixed by UDP; the application decides what to do.
- Light: an 8-byte header and no waiting for acknowledgements, which keeps delay low.
Side by side
| TCP | UDP | |
|---|---|---|
| Connection | Handshake before data | None |
| Delivery | Guaranteed, in order | Best effort |
| Header size | 20 bytes or more | 8 bytes |
| Delay | Higher; waits for lost data | Lower; never waits |
| Typical use | Web, email, file transfer, remote login | Voice, video, DNS, DHCP, time sync, VPN tunnels |
Common ports
| Service | Protocol and port |
|---|---|
| Web (HTTP / HTTPS) | TCP 80 / TCP 443 (HTTP/3 uses UDP 443) |
| SSH | TCP 22 |
| Email submission | TCP 587 |
| DNS | UDP 53, TCP 53 for large answers |
| DHCP | UDP 67 and 68 |
| NTP time | UDP 123 |
| SNMP monitoring | UDP 161, traps on UDP 162 |
| SIP signalling | UDP or TCP 5060, TLS on 5061 |
| RTSP camera streams | TCP 554 control; video over RTP on UDP, or inside the TCP session |
Why voice and video prefer UDP
In a phone call or live camera view, a packet that arrives half a second late is useless. TCP would pause the stream to resend it; UDP skips it and keeps going, and the codec hides the small gap. That is why IP phones send speech over RTP on UDP, and why QoS and a voice VLAN matter more than retransmission for call quality. See also latency, jitter and packet loss.
What it means for firewalls and port forwarding
Firewall rules and port forwards name both the port and the protocol: opening TCP 5060 does not open UDP 5060. Because UDP has no session, firewalls track it with short timers, which is why VPNs and SIP phones send keep-alive packets. To check what is really on the wire, capture it with Wireshark or tcpdump. A secure internet gateway lets you write rules per protocol and port for each network zone.
FAQ
Frequently asked questions
What is the main difference between TCP and UDP?
TCP sets up a connection and guarantees that all data arrives in order, resending anything lost. UDP sends packets without a connection or delivery guarantee, which makes it faster and lower in delay.
Is UDP faster than TCP?
UDP has less overhead and never waits for lost packets, so it has lower delay. For bulk transfers on a good link, TCP reaches similar speeds; the difference matters most for real-time voice and video.
Does DNS use TCP or UDP?
Normally UDP port 53. It switches to TCP port 53 for answers that are too large for a single UDP packet and for zone transfers between DNS servers.
Which protocol do IP cameras use?
Control and setup use TCP (for example RTSP on port 554 and the web interface on 80 or 443). The video itself is sent over RTP, either on UDP or carried inside the TCP connection when UDP is blocked.
Related
Keep reading
The seven OSI layers in plain words, with the devices and protocols that work at each one, how they map to TCP/IP, and how to use the model to troubleshoot.
Read more →Subnet Mask and CIDR Explained, With a /24 to /30 Cheat SheetWhat a subnet mask and CIDR such as /24 mean, how many usable addresses each size gives, and how to plan subnets for staff, guests, cameras and phones.
Read more →What Is NAT? Network Address Translation and Port Forwarding ExplainedNAT lets many devices with private IP addresses share one public address. How NAT and port forwarding work, private ranges, CGNAT, and NAT's security limits.
Read more →Ideal Network Architecture for Small and Medium BusinessesRead more →Need help designing your network?
Navijin engineers provide free design consultations, bills of materials and quotations for business projects.