π 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..
π All K-buckets in Kademlia explained MCQs
Q1. In the RTP packet header, what is the size of the Version (Ver) field?
π 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?
π 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?
π 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?
π 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?
π 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 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?
π 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?
π 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 packets, what is the consequence for detecting packet loss?
π Explanation: When the sequence number reaches its maximum () and wraps to zero, the receiver must interpret numbers modulo . 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?
π 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?
π 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.