let’s transmit these (binary) messages:
0010110001001111110 to represent “start/end of message”01111110 doesn’t occur within messages accidentally:
11111 in message with 111110111110 with 11111011111100 and 000001110111111001111101000111111100000011101111110hashes used to check messages called checksums
used at data link layer and upper layers
provides high probability we discard corrupted messages
IPv4, TCP —
Ethernet
let’s transmit these (binary) messages:
00101100010put 3-bit message size at beginning of messages
read header, then determine number of bits to read before next header
assumption: no gaps between messages?
problem: messages can contain 010 or end with 01
one solution: replace 01 in messages with 011
"" \(\rightarrow\) \"\ \(\rightarrow\) \\foo \R"3"13\ using "foo \\R\"3\"13\\"suppose instead of transmitting 0 or 1
physical layer transmits 0 or 1 or 2 or 3 or 4
probably going to ‘waste’ one of these values
idea: take advantage of leftover ‘symbol’ 4
use it to send start/end
| A. any 0000 |
| A. any 000 |
| B. any 00 |
| C. any 0 |
sending 10 and 01
sending 1 and 001
oops!
textbook example: start/end = 01111110
with purely size-based framing
with start/end marker idea
suppose all packets are same size
‘‘clock-based framing’’
example: SONET looks for start symbol every 810 bytes
flipping bits basically has same problems as synchornization
hashes used to check messages called checksums
used at data link layer and upper layers
provides high probability we discard corrupted messages
IPv4, TCP —
Ethernet
implement send+receive messages (strings of bytes) using bits
send_message(MESSAGE)
handle_bit_from_network(BIT)
but:
# In the given code for the assignment:
def bytes_to_bits(the_bytes):
result = bytearray()
for a_byte in the_bytes:
for i in range(8):
result.append(0 if (a_byte & (0x1 << i)) == 0 else 1)
return result
bytes_to_bytes(b'\x93') == bytearray([1,0,0,1, 0,0,1,1])