# Trying to understand IGMPv3 Max Response Code algorithm

In IGMPv2, the Max response time is an 8-bit value each unit encoding 0.1 seconds. The typical max response time is 100 resulting in a 10 second max response time.

In IGMPv3, if the Max response code is < 128, the calculated time is the same. But per https://www.rfc-editor.org/rfc/rfc3376 section 4.1.1:

   If Max Resp Code < 128, Max Resp Time = Max Resp Code

If Max Resp Code >= 128, Max Resp Code represents a floating-point
value as follows:

0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+
|1| exp | mant  |
+-+-+-+-+-+-+-+-+

Max Resp Time = (mant | 0x10) << (exp + 3)


https://www.rfc-editor.org/rfc/rfc6636 section 4.2 gives an example:

For example, if one wants to set the Max
Response Time to 20.0 seconds, the Max Resp Code should be expressed
as "0b10001001", which is divided into "mant=0b1001" and "exp=0b000".


I don't see how 0b10001001 results in 20 seconds. If the mantissa is 0b1001 (9 decimal) and we bitshift left 3 (exponent 0 + 3) that results in 0b01001000 = 72 decimal or 7.2 seconds.

How do I calculate the IGMPv3 response time for max response code values >= 128?

Neither RFC has relevant errata.

I think the part you misunderstood in RFC 3376 Section 4.1.1 that you quoted:

Max Resp Time = (mant | 0x10) << (exp + 3)


I think it could be clearer (not mixing binary and hexadecimal), but as far as I can gather:

(1001 OR 10000) = 11001 -> 11001^11 = 11001000 = Decimal 200


You must OR 0x10 to the matissa, which is one binary digit larger than the mantissa, so you prepend a binary 1 to the mantissa before shifting the exponent + 3.

This is something that perhaps should be sent in as errata.

Ron's hint is very close - in binary floats, the leading 1 is implied and not actually stored in the representation. It simply doesn't make sense to have anything else but a leading 1 in the (normalized) mantissa, so actually storing it would waste a (precision) bit.

The | 0x10 part in the formula expresses this.

See https://en.wikipedia.org/wiki/Floating-point_arithmetic#Internal_representation for the IEEE 754 format:

In the IEEE binary interchange formats the leading 1 bit of a normalized significand is not actually stored in the computer datum. It is called the "hidden" or "implicit" bit.