Search code examples
data-structuresip-addressipv4

Design a 50-bit globally unique ID


Every host in an IPv4 network has a 1-second resolution real-time clock with battery backup. Each host needs to generate up to 1000 unique identifiers per second. Assume that each host has a globally unique IPv4 address. Design a 50-bit globally unique ID for this purpose. After what period (in seconds) will the identifiers generated by a host wrap around?

Answer is given 256 .


This question is topic of data-structure , since here , I need to find correct 50 bit global id. It asked here before. I'm not satisfied, but don't have enough reputation to make any comment there .


My attempt :

We have 50 bits in Unique ID. total possible unique IDs with 50 bits = 2^{50}

Fortunately, we have 32 bit unique IP address with every host. To make the IDs to be unique, we can prepend this 32 bits with each unique ID.

So, we need to generate only the remaining 18 bits. hence 2^{18} combinations are possible.

It is given that every host generates 1000 IDs per second.

hence, to generate 2^{18} combinations, it will take 2^{18} / 1000 seconds ~= 262.144 seconds

What I'm missing to find correct answer ? Can you explain little bit .


Solution

  • The question is very strangely worded, but it's clear that the ID you're expected to use has 32 bits from the IP address, 8 low-order bits from the clock and 10 bits from a counter. The 8 bits from the clock wrap around in 256 seconds.