TCP vs UDP

  • Transport layer provides one network connection to allow multiple application simultaneously. Much like street names have house numbers, transport layer creates 65000 ports in your computer per network connection.
  • These ports can be reserved and used by applications on your computer.
  • One application can use multiple ports at the same time if it wants.
  • Our segment will show up on the reciever side, when it is passed on from the network layer to the transport layer.
  • The segment will be examined to determine the destination port.
  • Then the message is unwrapped and delivered to port 80.
  • UDP
  • TCP
  • small packet sizes than TCP by about 60%
  • UDP header 20 bytes
  • TCP header 80 bytes
  • Connectionless: No connection to create and maintain
  • You dont have to create connection first before sending out data
  • You have more control of when data is being sent out
  • Data corruption is a common occurance on the Internet, UDP has a primitive form of error detection.
  • No compensation for lost packets
  • Packets can arrive out of order
  • No congestion control

Transmission Control Protocol

  • Since TCP is connection based, we have to first negotiate a connection before we can do anything. This procedure is known as a three-way handshake.
  • First, the initiator will ask the acceptor if it wants to set up a connection.
  • The acceptor will reply to the request and when the initiator recieves this reply, it will send a packet to the acceptor that acknowledges that the connection is now established.
  1. Retransmission:
  • When a sender doesnt get an acknowlegement after a certain period of time, it will assume that the packet got lost on its way. So, it will send it again-.
  • Because segments are ordered in TCP, it implements in-order delivery.
  • Although packets may come out of order, TCP rearranges them before sending them to application.
  • Delays transmission when the network is congested
  • Bigger header
  • Data doesnt always sent out immeditaley
  • side effect of congestion control
  • Hence real time conversation will not feel real time as you wanted to be
  • As you can see, congestion control can be a nuisance or an enhancemewnt
  • Bigger overhead
  • Retransmission of packets, acknowledgement of packets
  • For example, to send HD video, you need lots of bandwidth. But if you are using TCP, you need more becaue of retransmission and acknowledgement. Hence, in this case it makes sense to use UDP than TCP.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ravi Kumar.

Ravi Kumar.

Building nextgen real estate platform at PriceHubble & podcaster at productlessons.com. I blog about products, business around products, and growth strategies.