My router has two protocols (and a "both" option) that I can select when setting up port forwarding: UDP and TCP. What is the difference between these two protocols and when would you select one over the other in port forwarding?

11 Answers 11


TCP is backed by acks and retries to make sure you data gets where it's going. UDP is connectionless and "fire and forget". UDP is mostly used for streaming type applications, where if you lose some data you don't need to try to send it again.

Which one you use depends on the application. For example, a web server uses TCP.

  • 3
    That makes sense - so if you're streaming a video there's not point in resending a missing frame later because you've already passed that point. Thanks
    – Guy
    Commented May 16, 2009 at 20:38
  • 15
    +1. Just to add, anyone looking for more in depth understanding should read one of W. Richard Stevens many excellent books on the subject. "TCP/IP Illustrated, v1" and "UNIX Network Programming" serve as excellent tutorials and references. Commented May 16, 2009 at 23:47

You can find a good summary here:

What is the difference between UDP and TCP internet protocols?

Both TCP and UDP work at transport layer TCP/IP model, but have very different usage.

The most important differences are:

  • Reliability:
    TCP: connection-oriented
    UDP: connectionless
  • Ordered:
    TCP: order of message receipt is guaranteed
    UDP: order is not guaranteed
  • Protocol weight:
    TCP: heavyweight, because of the connection/ordering overhead
    UDP: lightweight, very few overhead
  • Packets:
    TCP: streaming, data is read as a "stream," with nothing distinguishing where one packet ends and another begins. There may be multiple packets per read call.
    UDP: datagrams, one packet per one read call.

Frame structure

When data is sent over the network, it needs to be encapsulated into so called "frames." There are various methods of encapsulation depending on the protocol and topology that are being used. The following images show how TCP and UDP frame structures differ.

This is the TCP frame structure:

TCP frame

An this the UDP frame structure, much simpler:

UDP frame

Typical protocols which use TCP are HTTP, FTP and SMTP. Examples of protocols using UDP are DNS and DHCP.

  • @splattne - order of message receipt is guarantee, not transmission
    – Alnitak
    Commented May 17, 2009 at 6:46
  • @Alnitak: of course, you're right. I meant the receipt is guaranteed in the transmission order. I'll update to make that clear.
    – splattne
    Commented May 17, 2009 at 7:19

And the CEO level explanation:

UDP is when you throw your paper in the general direction of the bin.

TCP is when it misses, you throw exact copies of the same paper again and again until it falls into the bin. There would be paper wastage, even resent TCP packets result in wastage of network or system resources.

  • 1
    That is a very good "CEO level" explanation - I like it!
    – Keithius
    Commented Jun 4, 2009 at 12:36
  • I'm not a CEO, but why nobody told me this earlier ! :p Commented Jun 20, 2009 at 8:20
  • This is brilliant!
    – shylent
    Commented Jun 20, 2009 at 11:57

TCP and UDP are both protocols that run on top of IP. TCP has guaranteed delivery and UDP does not. You would select one or the other for port forwarding depending on what service you're trying to forward. HTTP, for instance is TCP. If you don't know what protocol the service you're trying to forward is, it's almost certainly TCP.


To answer other part of your question, you have to forward what your application uses. To forward HTTP traffic, select TCP. To forward TFTP traffic, select UDP. p2p programs mostly use both tcp and udp, so forward them both.

It all depends on the protocol and the program you are using.

  • you are not entirely right. dns uses also tcp/53, not so often but still [ eg. for zone transfer ].
    – pQd
    Commented May 24, 2009 at 10:40
  • yes. Also, it is entirely valid to send regular dns queries over tcp. I changed the example to TFTP, which exclusively uses UDP.
    – hayalci
    Commented May 25, 2009 at 11:30

As well as differences mentioned so far TCP also provides

flow control. Using a window mechanism the recipient limits how many octets (bytes) it wants to receive from the sender before the sender must wait for permission to send more data. The size of the window can be changed by the receiver as the conversation proceeds. This allows a receiver to 'throttle' the rate of data coming from a sender: UDP does not allow this and all a receiver can do is throw away data it cannot buffer or process on arrival.

some more technical facilities such as non-contiguous acknowledgement (uses selective acknowledgements to allow the sender to retransmit just a missing frame rather than the missing frame and subsequent ones that the receiver already has but could not acknowledge in the usual way), congestion handling and adaptive retransmission (adjusting the timer that decides how soon to resend a transmitted frame when an acknowledgement is not received). These are not relevant to UDP but help TCP to provide extra services over UDP without greatly increasing the network load for the same payload volume.


TCP makes an effort to ensure the data made it to the recipient; UDP does not.

  • Wrong. The IP protocol is not reliable and data loss can occur. TCP makes an effort to ensure that sent data (which is split into small parts and sent via IP packets) will make it to the recipient (by eventually resending small parts if required).
    – Anonymous
    Commented Jul 13, 2009 at 18:57
  • 1
    @ Anonymous - You basically restated what I said above. How am I wrong?
    – J. Polfer
    Commented Sep 22, 2009 at 14:07
  • I think you'll both find that IP is the underlying framework (stack) and the basic communication protocol that both UDP and TCP use. You can't actually communicate useful data over the internet using JUST IP, as far as I know -- even basic pings etc. use a protocol on top of IP (the other main one; ICMP).
    – Lee B
    Commented Apr 25, 2010 at 23:34

Never mind all the answers explaining one vs. the the other. For the purposes of setting up a port-forward, the rules are pretty simple: you need to choose TCP, unless the docs for the protocol/application you're using say to use UDP. Usually the ones that use UDP are related to streaming, or very simple things that favour lightweight protocols/speed over reliability (particularly DNS and NTP). Note that there are other protocols besides TCP and UDP too -- ICMP, tunneling protocols, etc.


The more wellknowned a protocol is, the more routers on the path intervenes with the protocol. Send tcp packets, and there's a big probability the received packets are highly mangled. UDP is usually not that mangled, and the other 254 IP paylod protocols are usually completely untouched.


User Datagram Protocol (UDP)

It is part of the base protocols of the Internet Protocol Suite. Programs on networked computers can send short messages sometimes called as datagrams. UDP does not guarantee any reliability( it happens datagram may arrive out of order, are duplicated, or are missing without any notice). The fact that no checking whether all packets are actually delivered is made, UDP proves to be faster and more efficient, for applications that do not need guaranteed delivery. UDP find its uses in such situations:

Time-sensitive applications. The problems due to delayed packets are avoided

It is also useful for servers that answer small queries from huge numbers of clients. UDP supports packet broadcast (conveys to all on local network) and multicasting (conveys to all subscribers).

Transmission Control Protocol (TCP)

It is often referred to as TCP/IP due to the importance of this protocol in the Internet Protocol Suite. TCP operates at a higher level, concerned only with the two end systems, (e.g. between web browser and a web server). TCP provides reliable, sequential delivery of a stream of data from one program on one computer to another program on another computer. Common uses of TCP regroup e-mailing support and file transfer and Web applications. Among its management tasks, TCP controls message size, the rate at which messages are exchanged, and network traffic congestion. As for IP, it handles lower-level transmissions from computer to computer as a message transferred across the Internet.


Well both are network protocols built on top of something called Internet Protocol or IP. The Internet Protocol is the major protocol of the Internet and is for example what allows us to browse the web. That's why you will often see these protocols written as TCP/IP or UDP/IP. They are actually core protocols of the internet.

In both cases your data is split up into chunks called packets. TCP ensures that these packets get to their destination and in the correct order and without any errors.

UDP on other hand will not ensure that a data packet will even arrive. It will only ensure that if it does arrive it will be without error.

Typically, other protocols will run on top of TCP and UDP and are known as application protocols because they operate within an application and not within the operating system. Your web browse uses HTTP protocol which will use the TCP protocol.

Domain name lookups or DNS queries often use UDP but can also use TCP. A number of streaming services use UDP beneath another application protocols.

I hope that answers your question in simpler english.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .