UDP Flashcards

1
Q

What is UDP?

A

UDP (User Datagram Protocol) is a connectionless transport-layer protocol for lightweight and fast communication over IP networks, offering no reliability or order guarantees.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the key features of UDP?

A

Connectionless Service: No connection setup or teardown; direct communication.
Best-Effort Delivery: No built-in error recovery; packets may be lost, duplicated, or arrive out of order.
Supports multicast messaging.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are common applications of UDP?

A

Instant Messaging: e.g., ICQ.
Multicast Messaging: Efficient for multiple receivers.
Low-Latency Communication: e.g., Voice-over-IP (VoIP), streaming, and gaming.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the structure of a UDP datagram?

A

1.Header (8 bytes):
*Source Port (2 bytes).
*Destination Port (2 bytes).
*Length (2 bytes): Total datagram length.
*Checksum (2 bytes): For error-checking.
2.Data: Variable-size payload with the application message.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the purpose of ports in UDP?

A

Ports: Logical endpoints for communication.
Allow multiple applications to use the same network connection.
Examples of well-known ports:
*Port 25: SMTP (Email).
*Port 80: HTTP (Web).
*Port 90: SHTTP (Secure Web).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How is UDP encapsulated?

A

UDP datagrams are encapsulated in IP datagrams, with the following hierarchy:

Frame Header (network-specific).
IP Header (internet addressing).
UDP Header (port and checksum data).
User Data (application message).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the advantages and limitations of UDP?

A

Advantages:
*Minimal overhead.
*Fast and suitable for real-time applications.
Limitations:
*No reliability, retransmission, or acknowledgment.
*Applications must manage reliability and data ordering.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Provide an example of sending and receiving data using UDP in Java.

A

Sending Data: DatagramSocket socket = new
DatagramSocket(16789);
String msg = “hello”;
String IP = “229.201.35.83”;
InetAddress address = InetAddress.getByName(IP);
DatagramPacket outputPacket = new
DatagramPacket(msg.getBytes(), msg.length(), address,
12465);
socket.send(outputPacket);

Receiving Data: DatagramSocket socket = new
DatagramSocket(16789);
byte[] data = new byte[256];
DatagramPacket inputPacket = new DatagramPacket(data, 256);
socket.receive(inputPacket);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly