Message Framing, Part 4


Past entries that you should have read by now:


After the message encoding is communicated, the framing protocol starts to diverge based on the mode record that was provided.


In the modes used by TCP, which are all duplex and half-duplex communication modes, there is now an opportunity for the two sides to negotiate additional framing options. This is also the first time that the communication backchannel has data to exchange. In the modes used by MSMQ, which are all one-way communication modes, there is no negotiation capability so these described records are not present.


Optionally, the initiator of the connection sends an upgrade request record to negotiate additional framing options. An upgrade request record starts with the byte 9 followed by the size of the upgrade string and followed by the upgrade string itself. An upgrade string is an opaque blob that uniquely identifies the upgrade. The size is encoded in the usual way. We happen to use MIME content types to name our upgrades because the upgrades we've implemented so far are all preexisting standards.


The receiver indicates its acceptance of an upgrade by sending an upgrade response record. An upgrade response record is the byte 10. When we get to talking about errors, I'll explain what happens if the receiver doesn't accept the upgrade.


After an upgrade is accepted, the upgraded stream wraps all of the protocol transmissions. For example, if the upgrade was to negotiate an additional framing option of SSL communication, at this point an SSL handshake would be exchanged. All future transmissions would be over the SSL connection. Due to the way that upgrades wrap the underlying byte stream to add new protocol options, these are called stream upgrades.


Once the initiator is done sending upgrade requests, the next record is a preamble end record. A preamble end record is the byte 12. We know that the receiver and initiator are synchronized on all of the data that has been transmitted so far when the initiator receives back a preamble acknowledgment record. A preamble acknowledgment record is the byte 11.

Comments (3)

  1. It’s snowing again. Like every other time in Southern-most NJ (near Philly) if it accumulates more than an inch, I will be astonished. Very unlike where we used to live in New Hampshire, where for 2 years, they have at least weekly snow storms of 8 or

  2. geff zhang says:

    在TCP/IP协议栈中,当数据通过协议栈向下流动时,每一层都要给数据增加控制信息用于确保正确的传递。控制信息放置在被传送数据的开始,称之为包头,这种在协议栈中每一层都增加传递信息的过程称为封装。也就是…

Skip to main content