Some Protocol Pearls

Some Protocol Pearls

  • Provide end-to-end reliability:
  • A request sent from one entity to another often must have confirmation that it was accepted or not by the destination entity.? This is typically accomplished with a positive/negative response scheme.
  • The protocol must provide a means for a sender to correlate a response (positive or negative) with its original request.? This is typically accomplished with a unique sequence number inside each request, and with the resultant response referencing that unique number.
  • A timeout policy for a sender to detect an unresponsive receiver.? If a response, positive or negative, has not been received within the timeout period, the sender can retry or notify its client application of the timeout.
  • Provide independence from other protocol layers.?
  • There should be no implicit bindings, or dependencies based on other layers.? Dependencies are common in protocols built on top of (Bluetooth Low Energy) BLE, because BLE’s “Characteristics” provide a tempting way to separate message behaviors.? A callback from a specific characteristic implies a message type or category, and the temptation is to use BLE’s characteristics as a routing mechanism.? The result is that? many homegrown protocols running over BLE are not portable to other, non-BLE protocols if the routing mechanism is on a BLE characteristic.?
  • Separate the routing mechanism from the command (i.e., “opcode”) of a message.?
  • For example, it’s tempting to have the message command field also serve as the routing field, as in “This command goes here” and “That command goes there.”? This overloading of the command field greatly limits the protocol’s ability to evolve.? The command space (often based on an 8-bit or less command field) becomes limited because it’s totally flat? (256 command limit means 256 destination limit).? Whereas when the routing field is separate from the command field, the space becomes hierarchical, and there can be 256 distinct commands per routing destination. Further, with the overloaded command field, it becomes difficult to route the same command to multiple destinations.? For example, it is often useful for a controlling application to send a “Shutdown” or “Pause” command to multiple destinations; this can be accomplished with a single message sent to a destination that represents a group of destinations, as in multicast.? Without a separate routing field, the Shutdown or Pause would have to be sent to each destination separately.??
  • Provide a means of versioning for backward compatibility.?
  • This way, as a protocol evolves (very common with homegrown protocols), it provides a means for each end to settle on a compatible version of the protocol, or at least for the receiver of an incompatible version to opt-out.
  • Provide efficient utilization of the communications medium.?
  • Early protocols were built to only allow one unanswered message to be outstanding at a time, which results in the medium being under-utilized.? With a “Sliding Window” acknowledge scheme, messages can be sent back-to-back and the group of them acknowledged at once, resulting in efficient use of the medium.
  • Provide a pacing mechanism.?
  • A pacing mechanism provides a receiver with a means to control the pace at which the sender sends it messages.? In older protocols such as Bisync, this was done with a “WACK,” which meant “I am not ready to receive a message at the moment but please keep trying.”? More modern protocols provide a pacing window, which is a? number (window) of messages that can be sent without a pacing response.? The pacing response then clears the window and the sender can send a new window of messages.
  • Provide a chaining mechanism.?
  • Most protocols provide a message size field, which indicates the size of a single message payload.? However, often there is a need to send a stream of bytes that is longer (often much longer) than a single message payload.? A chaining mechanism is most often represented by two bits: a “Begin Chain” (BC) bit and a “End Chain” (EC) bit.? A single-message chain is indicated by both BC and ED being set.? A multiple-message chain begins with BC set, all middle messages with BC and EC not set, and the last message with EC set.
  • Provide a means to guarantee correct ordering of messages, in case that is important
  • Provide a connection capability to keep sessions between certain entities more secure.

要查看或添加评论,请登录

David Everett的更多文章

  • A Simple Firmware Test and Control Protocol

    A Simple Firmware Test and Control Protocol

    This article describes a protocol that runs on top of our basic packet we designed in the last article; we can use this…

    1 条评论
  • My Dad and the X-13 Vertijet

    My Dad and the X-13 Vertijet

    How I wish that my dad were alive today to experience the current eVTOL revolution. His name was Lou Everett, and he…

    7 条评论
  • The Perfect Protocol Packet

    The Perfect Protocol Packet

    The last three projects I've worked on have required the development of custom data communications protocols. Whether…

社区洞察

其他会员也浏览了