I am reading about sliding protocols and in almost every book its written this:
Frames have sequence number 0 to maximum \$2^n – 1\$.
Why is the maximum \$2^n-1\$?
protocol
I am reading about sliding protocols and in almost every book its written this:
Frames have sequence number 0 to maximum \$2^n – 1\$.
Why is the maximum \$2^n-1\$?
Best Answer
I think you mean from \$0\$ to a maximum of \$2^n - 1\$.
That's because to represent from \$0\$ to a maximum of \$2^n\$ you'd need another a whole extra bit in binary.
For instance if \$n=8\$ then you have values from 0 to 256 (\$2^8\$). That's 257 values (zero counts!) which requires 9 bits, but 0 to 255 (\$2^8 - 1\$) is the entire range of 8 bits or 256 values.
If you have Windows 7, you can play with the "Programmer's" mode on the calculator. It helps visualize some of these concepts. I use it all the time, especially when writing assembly.