I used to conduct a lot of interviews and one of the questions I typically asked people interviewing for network admin positions is "what's the difference between TCP and UDP?" I was frankly shocked at some of the answers I received by these so-called network professionals. One of the more interesting answers I received was "UDP is a protocol for users and TCP is a protocol for transmissions". Hmm. Anyway, the short answer to the title of this article is "NO" - UDP is not stateful. I'll explain in simple terms why by defining exactly what "stateful" means, explaining UDP in simple terms, and explaining TCP in simple terms. Sounds pretty exciting, right?
Stateful = I expect something
Stateless = I expect nothing
What Is Stateful?
Stateful means the item you are describing is aware of its "state." For instance, I am a stateful person. If I say hello to you, I enter a "state" of expectation for an answer back. If I don't receive a response I may say hello again, thinking you may not have heard me the first time. If I'm ignored again, I may give up and go cry myself to sleep for being neglected! Eventually, I exit the "state" of wanting an acknowledgment for my hello and move on to something or someone else.
In terms of technology protocols, like TCP/IP, the same rules apply. A stateful protocol expects a response. A stateless protocol doesn't care. A stateless protocol is akin to a TV broadcast - the broadcast doesn't care if you watch it, if you like it, if you talk to it, etc. The TV broadcast has no expectations!
Spray and Pray
UDP is also known as "Spray and Pray" - spray the packets on the wire and pray they get to their destination!
UDP is StateLess
In case you haven't guessed, UDP (User Datagram Protocol) is Stateless. This means it has no expectations. Here are some of the characteristics of the expectationless UDP:
- I don't care if what I send is received
- I don't care if one of my packets was lost in transit
- I don't care if you acknowledge my existence
- I don't care if you like me or simply discard me
- Basically, I'm a slacker and don't care about anything
TCP - the Stateful Overachiever!
TCP (Transmission Control Protocol), in contrast to UDP, is stateful. TCP has expectations! Here are some of the characteristics of TCP:
- I expect you to acknowledge my message
- If you don't acknowledge my message, I may assume you didn't hear me and I will retransmit it again
- I expect us to interact nicely and acknowledge each other on a regular basis
- I'm quite obsessive and like to track our conversation. This way I can resend something if you miss it.
- I like to leave on good terms by politely ending our conversation
Manas on July 16, 2016:
Grt 8 , nice , wow and awesome thanks for the above explanation .....
Coad on May 04, 2014:
thank you :)
Imran Aziz on March 21, 2012:
Best explanation! Thanks
Heena on September 22, 2011:
Manna in the wild from Australia on December 15, 2010:
I like to think that stateful implies 'memory'. You need memory to hold 'state' as in the 'expectation' of a reply. It comes from the comp-sci taught mathematical abstraction of a "finite state machine" which is described as a building block that has finite internal memory, and input and an output.