Bitit

| Day (5 bits) | Month (4 bits) | Year (7 bits) |
Here is demonstrated how information (less than 8 bits) is set into bytes for transmission through a socket and how the information is extracted. The assumption is that Day uses 5 bits, Month uses 4 bits and Year (with 2 digits) uses 7 bits. First set the values in decimal (or binary) and then shift the fields to their position in the frame. Then XOR the shifted 16 bit values, divide them to bytes. At the receiving end use the correct Mask and shift to extract the values sent one by one. See the slides for how this all is done in Java.
Day (dec): Day (bin):
Month (dec): Month (bin):
Year (dec): Year (bin):
Shift (left): Shifted bits:
Shift (left): Shifted bits:
Shift (left): Shifted bits:
xor:
First Byte:
Second Byte:
→ Bytes are sent over a socket → and then combined at the receive end → to extract the info from the different (bit) length fields →
Combined bytes (in binary):
Set the mask in hex and shift accordingly
The mask (hex): The mask (bin): The mask (dec):
Shift (right): Shift (right):
Shifted value (bin): Masked value (bin): Masked value (dec):