Communications

From OSDev Wiki
Jump to: navigation, search

Contents

Introduction

There are numerous mechanisms, techniques and protocols for getting data from one place to another, and many have a long history, an established implementation, and industry-standard terms. This page tries to enumerate the ones used for computing, so therefore what an Operating System may need to provide drivers and modules for.

To provide some sort of order, this page first differentiates between the most basic of implementations: how many "wires" are used simultaneously to send data.

  • "Parallel" implies that there are sufficient data wires side-by-side to send a single datum (byte, word or whatever) at once, with extra wires for control;
  • "Serial" implies that a single datum needs to be split into multiple parts first - usually the individual bits - and then sent over a smaller number of wires (as few as one). There may or may not be control wires as well.

Within the above two categories, the different techniques are listed in approximate complexity order. They start by differentiating themselves from other techniques - which is sometimes only subtle - and then usually link to other Wiki pages dedicated to the topic.

Common Terms

Many terms are used in the Communications arena, and sometimes they're used ambiguously. The following are the usual definitions of these terms:

Communications

Link 
The connection between two devices. This could be multiple wires in a cable, or even wirelessly over a radio link.
Channel 
A single path on a link, carrying one stream of data. A link may comprise of multiple channels; the usual number is two, one in each direction.

Characteristics

Synchronous 
1. Synchronous communications implies that the data is sent in lock-step with a clock, often provided on another wire. The receiver can notice the change of state of the clock, and "sample" the data wire/s during defined transitions (e.g. rising edge, falling edge, or both).
2. Synchronous communications often implies "continuous": there is always data, but that data may be "filler" if there's nothing to communicate.
Asynchronous 
1. Asynchronous communications implies that each side maintains its own clock, and sends data at a predetermined rate (often called "baud rate").
2. Asynchronous communications often implies "at any time": there is usually "dead space" on the link, and then one side or the other will burst into life, transmit the data, then go idle again.

Directions

Simplex 
Data can only ever flow over the link in one direction.
Duplex 
Data can flow over the link in both directions.
Full-Duplex 
Data can flow over the link in both directions simultaneously.
Half-Duplex 
Data can flow over the link in either direction, BUT only in one direction at a time.
A perfect example is the walkie talkie: only one side can transmit at a time, or else neither side will hear the other - hence the tradition of saying "Over!" just before releasing the Press-To-Talk (PTT) button.

Parallel Communications

Bus

Parallel Port

Small Computer System Interface (SCSI)

Peripheral Component Interconnect (PCI)

PCI Express (PCIe)

Although this looks to the computer as a (nearly) standard PCI bus, strictly speaking this is a Serial interface. At the lowest (electrical) level the data is sent over a single channel instead of a parallel bus, reducing the pinout and allowing for a simpler, thus faster interface. To further increase speed, PCIe supports "lanes", which are actually parallel PCIe data channels with only one set of control wires - back to being parallel!

Serial Communications

General Purpose I/O (GPIO)

1-Wire Interface

The (misnamed) one-wire interface needs a second wire: the ground. But it does use just the one wire for each direction of communications, by requiring both sides to use a transmitter that can be electrically turned off (tri-state or open drain). By each side connecting both their transmitter and receiver to that one wire, then either side can transmit - just not both at the same time (half-duplex).

Single-Wire Protocol (SWP)

The (misnamed) Single-Wire Protocol needs a second wire: the ground. But it does use just the one wire for each direction of communications - simultaneously. In the Master-to-Slave direction, the Master communicates HIGHs and LOWs with differently-timed pulses. The Slave communicates HIGHs and LOWs by applying a load (or not) during those pulses. The Master detects the amount of current drawn by the Slave to determine what state the Slave is transmitting.

Inter-Integrated Circuit (I²C)

This is often spelled "I2C" for convenience (pronounced "Eye Two See"), or occasionally "IIC", but the correct name comes from the idea that the two "I"s look like they multiply together, hence the pronunciation "Eye Squared See".

The I²C cable has two signals, plus ground: a Clock signal (SCK) that is always generated by the Master; and a Data signal (SDA) that is generated by whichever device is currently the transmitter - either the Master commanding or requesting something, or the Slave replying.

Note that multiple Slaves can be connected to the same I²C bus simultaneously. Part of the protocol is that the Master sends the address of the Slave that it is communicating to: only that Slave should respond.

Serial Peripheral Interface (SPI)

The standard SPI cable has four signals, plus ground:

  • A Master-driven Clock (SCK) to clock data into and out of the Slaves;
  • A Master-driver Slave Select (SS) to select and activate which Slave is being commanded;
  • The Master-Out/Slave In line (MOSI) data line; and
  • The Master-In/Slave-Out line (MISO) data line.

The Master uses SCK to clock out its commands on MOSI while simultaneously clocking in the Slave's (previous) response on MISO.

The naming makes it obvious which direction the signal flows - but not so obvious is that there can be multiple Slaves. If there are, they can either be on their own individual SS lines (meaning that the Master needs a dedicated SS line for each of them), or on a single SS line.

To allow the latter (since all Slaves would be activated simultaneously), the MOSI/MISO lines need to be connected as a cascaded ring. The Master sends out enough information for ALL the devices in the correct order, while receiving the responses from the last command in the same order.

  • The first bits sent out by the Master are for the last device in the chain, and pass through each device before reaching their destination; while the last bits sent are for the first device. Only when SS is dropped is the received data that's still in the Slaves' buffers "actioned" by the Slaves.
  • To receive the responses, the Master again raises SS to all the devices, and clocks the Slaves' responses in. Again, the first device's response passes through all the other devices before arriving at the Master as the last data received.

Dual SPI

After SPI had been used for a while, it became apparent that the normal usage was for the Master to send out its command while ignoring the previous response, and then send out a "Do Nothing" command while clocking in the response to the original command. Although this was less efficient of the bandwidth available, it was far easier for programmers to think about - especially if the program needed the results of the previous command before it could decide what the next command should be.

That meant that the dedicated Input and Output lines were less efficient than a different model: keep the two data lines, but make them bidirectional, so that they were both used to send two bits of the command or two bits of the response. This meant that the same amount of data could be transferred in half the number of clocks.

Quad SPI

The "Quad" in the name is because Quad SPI devices have four data lines rather than the two of SPI and Dual SPI. It can still be used in original SPI or Dual SPI modes - the last two data lines are ignored - but in full Quad SPI mode, commands and responses can be sent four bits at a time rather than two or one.

Serial Port

Most people who program computers know what a serial port is, since that's an easy way for the program to communicate in real time to the operator. The most common version is that used for the COM port on the PC: a (now) 9-pin connector that has a Ground, Receive (RX) and Transmit (TX) pin, plus a "baud rate" setting you've got to get right to communicate anything!

But a generic port that can be simply connected to an external device is often much more complex that this, yet still goes by the name "Serial Port".

RS-232 / RS-422 / RS-485

These terms define the electrical standard used on the wires for a serial port.

Comm Port

Synchronous Port

HDLC

X.25

Controller Area Network (CAN)

This is often used in vehicles, connecting sensors and switches to the Engine Management Computer, Body Control Module and dashboard gauges and lights. All the devices are connected to the same cable, and each broadcast packets of information for any other device to receive, interpret, and act on (change something else, or update a display). Using the one cable reduces the number of dedicated cables required, which saves a lot of weight, but it means that each device needs to be able to turn off its transmitter, and to be intelligent enough to decode the packets of information.

MilStd-1553 Bus

This is often used in aircraft, connecting sensors and switches to the Flight Control Computer and instrument clusters. All the devices are connected to the same cable, and each broadcast packets of information for any other device to receive, interpret, and act on (change something else, or update a display). For redundancy and safety, typically two separate cable runs are connected to each device. Using only two cables reduces the number of dedicated cables required, which saves a lot of weight, but it means that each device needs to be able to turn off its transmitters, and to be intelligent enough to decode the packets of information.

Universal Serial Bus (USB)

Ethernet

This is arguably the most complicated Serial interface, despite it essentially only having two data channels. It's the protocol/s that are communicated on top of this electrical protocol that complicate things: most commonly the whole TCP/IP suite used by the Internet.

Internet Protocol (IP)

IP version 4 (IPv4)

IP version 6 (IPv6)

UDP

TCP

HTTP, HTTPS, E-mail, ...

Personal tools
Namespaces
Variants
Actions
Navigation
About
Toolbox