πŸŽ“ BookMCQ
← Back to 29. Peer to Peer Paradigm

πŸ“ K-buckets in Kademlia explained (10 MCQs)

Bounded Contact Lists for Distance Classes

A Kademlia k-bucket is a bounded list of contacts whose node IDs fall within one XOR-distance range from the local node. The parameter k sets the maximum number of contacts retained. Together, the buckets give each peer a compact routing view covering different portions of the identifier space. XOR ordering controls lookup decisions regardless of physical network distance between peers.

Ranges Based on the Highest Differing Bit

For an m-bit keyspace, a bucket corresponds to a distance interval between powers of two, commonly 2^i up to but not including 2^(i+1). The interval index reflects the most significant bit where two identifiers differ. Close and distant contacts therefore occupy different buckets. Bucket structure bounds state while covering distinct XOR distance ranges around each node.

Least-Recently-Seen Contact Management

Kademlia's original contact policy keeps useful long-lived nodes by tracking when they were last heard from. When a bucket is full and a new contact arrives, the node may ping the least recently seen contact. If it responds, the old contact is retained; if it fails, the new contact can take its place. Responses can add closer contacts before the next query round.

Illustrating a Bucket with Capacity Two

Assume k equals two and a bucket already holds contacts A and B, with A least recently seen. A new contact C is discovered. The node probes A; if A responds, C is not inserted into that full bucket, while an unresponsive A can be replaced by C. XOR values, not decimal subtraction, determine which candidate is nearer here.

Resilience and Useful Long-Lived Contacts

This policy avoids discarding established contacts merely because a newcomer appears, which can improve routing stability when peers frequently join and leave. Buckets also provide alternatives when a destination is unavailable. Implementations may adjust refresh and replacement details, but the capacity and distance-class principles remain. Availability still depends on replicas and reachable contacts near the key.

K Is Not the Number of Network Nodes

'k is the total network size' is false because it limits contacts per bucket. 'A bucket groups peers by IP subnet' confuses identifier distance with addressing. 'The newest contact always replaces the oldest' reverses the original policy, which tests the least recently seen contact before replacement. Distance measures identifiers, not latency, ownership, or physical separation between peers.

Bucket Index and Replacement Scenarios

For exam questions, identify the distance class from the highest differing bit, explain why a node has multiple buckets, and apply the full-bucket ping scenario. Distinguish the bucket capacity k from lookup parallelism, often denoted alpha, and from the total number of peers in the overlay. Write each XOR result before ranking candidate contacts for lookup.

K-Bucket Capacity and Contact Terms

  • k-bucket - Bounded contacts in one distance class..
  • k - Maximum contacts retained in each bucket..
  • XOR range - Identifier distance interval represented by a bucket..
  • Least recently seen - Contact not heard from for longest..
  • Ping - Reachability test sent to a contact..
  • Replacement - Substituting an unresponsive contact with newcomer..
3
Easy
5
Medium
2
Hard

πŸ“ All K-buckets in Kademlia explained MCQs

Q1. In the RTP packet header, what is the size of the Version (Ver) field?

A.2 bits βœ…
B.4 bits
C.8 bits
D.1 bit
πŸ’‘ Difficulty: easy | βœ… Correct: A

πŸ“– Explanation: The Version field occupies exactly two bits, allowing values 0‑3. RTP currently defines version 2, which fits within this 2‑bit space. The small size keeps the header compact while still permitting future version extensions. Hence, the correct answer is the 2‑bit option.

Q2. If the Padding (P) bit is set to 1, how must the receiver compute the actual RTP payload length?

A.Add the padding length to the UDP length
B.Use the Sequence number to infer length
C.Subtract the value of the last byte from the UDP length βœ…
D.Ignore the padding and use the UDP length directly
πŸ’‘ Difficulty: easy | βœ… Correct: C

πŸ“– Explanation: When P=1, the last byte of the packet indicates how many padding bytes were added. The receiver subtracts this value from the total UDP length (minus the RTP header) to obtain the true payload length. This subtraction yields the correct payload size.

Q3. When the Extension (X) bit equals 1, what additional structure appears in the RTP header?

A.A CSRC list is appended
B.An extension header follows the basic header βœ…
C.The payload type field is expanded
D.A new timestamp field is inserted
πŸ’‘ Difficulty: easy | βœ… Correct: B

πŸ“– Explanation: Setting X=1 signals that an optional extension header is present immediately after the fixed RTP header. This extension can carry extra information defined by the application. No other fields are altered, making the extension header the sole addition when X is set.

Q4. How does setting the Marker (M) bit affect stream synchronization compared to leaving it cleared?

A.It causes the packet to be encrypted
B.It indicates that the packet carries a control message
C.It has no effect on synchronization
D.It signals the end of a frame, allowing the decoder to know frame boundaries βœ…
πŸ’‘ Difficulty: medium | βœ… Correct: D

πŸ“– Explanation: The Marker bit is used by many codecs to mark significant events, such as the end of a video frame. When set, the decoder can recognize frame boundaries, improving synchronization and reducing jitter. Leaving it cleared provides no such cue, potentially causing misalignment.

Q5. If the Contributor Count field is set to its maximum value, how does the RTP header size change?

A.Header grows by 60 bytes (15 CSRC entries) βœ…
B.Header size remains unchanged
C.Header grows by 4 bytes
D.Header grows by 15 bits
πŸ’‘ Difficulty: medium | βœ… Correct: A

πŸ“– Explanation: A maximum contributor count of 15 means fifteen 32‑bit CSRC identifiers are appended. Each CSRC adds 4 bytes, so the header expands by 15Γ—4=6015 \times 4 = 60 bytes. No other fields change size, making the 60‑byte increase the correct effect.

Q6. In what way does the Timestamp field assist a jitter buffer in handling variable network delay?

A.It encodes the codec type
B.It provides the sampling instant, enabling proper playout timing βœ…
C.It indicates packet loss
D.It determines the packet size
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: The Timestamp conveys the sampling instant of the first byte in the payload. A jitter buffer uses this value to schedule playback at the correct moment, compensating for network delay variability. By aligning packets according to their timestamps, smooth media delivery is achieved.

Q7. When transmitting encrypted RTP payloads that require padding, which fields must be configured and how does the receiver recover the original payload length?

A.Set P=0 and X=1; receiver uses extension header length
B.Set P=1 and M=1; receiver ignores padding
C.Set P=1; receiver reads last padding byte to subtract from UDP length βœ…
D.Set X=0 and M=0; receiver uses sequence number
πŸ’‘ Difficulty: hard | βœ… Correct: C

πŸ“– Explanation: For encrypted data, padding is added and indicated by setting P=1. The last byte of the packet contains the padding length. The receiver subtracts this value from the total UDP length (after removing the RTP header) to obtain the true payload size, ensuring correct decryption.

Q8. If the 16‑bit Sequence Number wraps after 2162^{16} packets, what is the consequence for detecting packet loss?

A.Loss detection becomes impossible after wrap
B.Wrap causes duplicate packets
C.Receiver must compare relative ordering using modulo arithmetic
D.Sequence numbers are ignored βœ…
πŸ’‘ Difficulty: hard | βœ… Correct: D

πŸ“– Explanation: When the sequence number reaches its maximum (6553565535) and wraps to zero, the receiver must interpret numbers modulo 2162^{16}. By comparing the difference between successive numbers, it can still identify gaps that indicate packet loss, despite the wraparound.

Q9. How does RTP differ from TCP regarding out‑of‑order delivery, and which RTP header field enables the receiver to reorder packets?

A.RTP allows out‑of‑order packets and uses the Sequence Number field to reorder βœ…
B.RTP guarantees in‑order delivery like TCP
C.RTP uses the Timestamp field for reordering
D.RTP relies on the Payload Type field
πŸ’‘ Difficulty: medium | βœ… Correct: A

πŸ“– Explanation: RTP does not enforce reliable, in‑order delivery; packets may arrive out of sequence. The 16‑bit Sequence Number field provides a logical order, enabling the receiver to reorder packets before decoding. TCP, by contrast, ensures ordered delivery at the transport layer.

Q10. What is the relationship between the Payload Type field and codec negotiation in RTP streams?

A.Payload Type directly carries the codec name
B.Payload Type value maps to a codec agreed upon in SDP, enabling dynamic codec selection βœ…
C.Payload Type indicates packet size
D.Payload Type is unrelated to codec
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: During session setup, the SDP exchange assigns specific Payload Type numbers to codecs. The RTP header then carries this numeric value, allowing the receiver to select the correct codec for decoding. Thus, the Payload Type serves as a reference to the negotiated codec, not the codec itself.

πŸ”— Related Topics (MCQs)