Network Engineering
brian | Published: Feb. 17, 2024, noon | Updated: May 25, 2025, 9:05 p.m.
UDP
User Datagram Protocol(UDP), a layer 4 protocol, and is a connectionless protocol, meaning it does not establish a direct connection between the sender and receiver before transmitting data. UDP permits packets to be dropped instead of processing delayed packets, and this is useful because imagine if you were on a phone call, and every time a packet was missed, you would hear the same thing that person said over and over again every time a packet didnt come through. Instead, the packet is dropped and is continued with the latest packet.
Applications Ideal For UDP
1. Applications with Small responses: DNS(Domain Name System) which is a protocol that is used to to resolve domain names, such as "google.com" and convert them to IP addresses in order to establish connection. If I were to go to "google.com" the entire conversation would only take 2 packets, unlike TCP which would take 11. Below is an example of UDP
2. Applications that involve Live or streamed content
1. VOIP(Voice Over IP)-Which allows to have phone calls over the internet
2. Live TV or Multiplayer games. For videogames lets say you're playing call of duty, and a packet is dropped. You wouldn't want to focus on that dropped packet that was from earlier, you would much rather focus on the most recent events in real time.
TCP
It is one of the main protocols in the Internet Protocol (IP) suite and is also a layer 4 protocol.TCP provides reliable, connection-oriented communication between devices over an IP network. TCP, unlike UDP, is meant for 100% reliability. When TCP sends packets over the internet, you can be rest assured that they will be delivered successfully and whole, unlike UDP which can be delivered with missing packets.
Things to Note
1.Stateful, there is a connection between client and server
2. Requires 3 way handshake for TCP connection to be established
3. Every tcp segment are sequenced and ordered so that when they are delivered to the reciever they can re-order them
4. Lost segments are re-transmitted. When you send data to the reciever, the reciever will send back an acknowledgment indicating that it has recieved the data. During this period, the sender is keeping track of time, and once the time has reached a certain limit without recieving an acknowledgment, the sender will send the data again. The timer is used in case the packet is lost or corrupted.
TCP is Connection Oriented
TCP has a START and an END
1. A sends a packet(TCP SYN (synchronization) packet ) to B, asking it if it can speak tcp with it (this corresponds to TCP handshake initiation)
2. B receives this packet (SYN packet), and sends a packet back (a SYN-ACK) packet to A agreeing ✓
3. A sends another (SYN-ACK) packet back to B, and then starts sending data
4. Once they're finished talking with each other
5. A sends another special packet FIN (finish) packet to B indicating it is done sending data
6. B responds, and the connection is closed