Flag field가 아닌 Data에 0x7E가 있는지 확인
0x7E -< 0x7D, 0x5E를 삽입
[링크 : https://blog.daum.net/trts1004/12109121]
232와 같은 비동기 전송일 경우 bit stuff를 적용하지 않는다고..?
Synchronous framing Because a flag sequence consists of six consecutive 1-bits, other data is coded to ensure that it never contains more than five 1-bits in a row. This is done by bit stuffing: any time that five consecutive 1-bits appear in the transmitted data, the data is paused and a 0-bit is transmitted. Asynchronous framing When using asynchronous serial communication such as standard RS-232 serial ports, synchronous-style bit stuffing is inappropriate for several reasons: Bit stuffing is not needed to ensure an adequate number of transitions, as start and stop bits provide that, Because the data is NRZ encoded for transmission, rather than NRZI encoded, the encoded waveform is different, RS-232 sends bits in groups of 8, making adding single bits very awkward, and For the same reason, it is only necessary to specially code flag bytes; it is not necessary to worry about the bit pattern straddling multiple bytes. Instead asynchronous framing uses "control-octet transparency", also called "byte stuffing" or "octet stuffing". The frame boundary octet is 01111110, (0x7E in hexadecimal notation). A "control escape octet", has the value 0x7D (bit sequence '10111110', as RS-232 transmits least-significant bit first). If either of these two octets appears in the transmitted data, an escape octet is sent, followed by the original data octet with bit 5 inverted. For example, the byte 0x7E would be transmitted as 0x7D 0x5E ("10111110 01111010"). Other reserved octet values (such as XON or XOFF) can be escaped in the same way if necessary. The "abort sequence" 0x7D 0x7E ends a packet with an incomplete byte-stuff sequence, forcing the receiver to detect an error. This can be used to abort packet transmission with no chance the partial packet will be interpreted as valid by the receiver. |
[링크 : https://en.wikipedia.org/wiki/High-Level_Data_Link_Control]
'모종의 음모 > HDLC' 카테고리의 다른 글
hdlc nrzi encoder / decoder (bit stuff 제외) (0) | 2022.08.29 |
---|---|
hdlc 프로토콜 - bit stuffing, endian? (0) | 2022.08.26 |
HDLC FCS ccitt-1 16bit crc (0) | 2021.12.06 |
HDLC 프로토콜(High level Data Link Control) (0) | 2021.07.27 |