We want to design a packet format that contains a date in the form: day / month / year. What should the packet look like? How many bits will really be (will be appropriate) needed to represent the individual parts of the packet?
Packet format for Date
Date (1-31) | Month (1-12) | Year (4 digit integer) |
5 bits | 4 bits | 10 bits |
There are 31 different possible values for date. If we use 5 bits then we can generate 31 different values (31< 2^5 ). Hence, 5 bits are needed for date.
There are 12 different possible values for month. If we use 4 bits then we can generate 12 different values (12 < 2^4). Hence, 4 bits are needed for month.
Largest 4 digit number is 9999. 2^10 = 1024. 2^9 = 512. Hence, 10 bits are needed to represent a year.
Hence, total packet length will be 5+4+10=19 bits.
Get Answers For Free
Most questions answered within 1 hours.