networking protocols
  • networking protocols
    • Networking protocols describe the way data is packaged to be sent between devices. Protocols can exist in any of the OSI network layers. David has described the network layers in his tutorial on networking transport.

      Different protocols are used at every layer, as in the example below, where UDP is used in the transport layer and IP is used in the network layer:

      this image is from Wikipedia.

      The application packages the data to be sent, and each subsequent layer adds a "header" that is used to describe the protocol and also identify the packet's source and destination (where it originates from, and where it is going, respectively).

  • IP4: internet protocol
    • The Internet Protocol (IPv4) describes how you send a packet of data across from one computer to another through the internet. This protocol is used in the network layer, as defined in RFC791. Section 3.1 in the RFC describes the structure of an IP packet as follows:

          0                   1                   2                   3   
          0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 
         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         |Version|  IHL  |Type of Service|          Total Length         |
         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         |         Identification        |Flags|      Fragment Offset    |
         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         |  Time to Live |    Protocol   |         Header Checksum       |
         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         |                       Source Address                          |
         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         |                    Destination Address                        |
         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         |                    Options                    |    Padding    |
         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      

      The details of this diagram are described in the RFC, but as a quick overview: each "tickmark" describes one bit of data -- for example, there are 4 -'s in the Version number, meaning there are 4 bytes to describe the version number of an IP packet. Two of the most important features of the packet are the source and destination addresses. The source address is the IP address of the machine that sent the packet, . IPv4 addresses are 4-bytes, typically written as a set of 4 8-bit numbers separated by a period, e.g. 18.85.23.106.

      See RFC791 for more details on IPv4.

  • IP6
    • IPv6 is the version of the Internet Protocol that is supposed to replace IPv4. It allows for 6 byte addresses, making it possible to address many more devices. It also has a simplified header structure:

         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         |Version| Traffic Class |           Flow Label                  |
         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         |         Payload Length        |  Next Header  |   Hop Limit   |
         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         |                                                               |
         +                                                               +
         |                                                               |
         +                         Source Address                        +
         |                                                               |
         +                                                               +
         |                                                               |
         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         |                                                               |
         +                                                               +
         |                                                               |
         +                      Destination Address                      +
         |                                                               |
         +                                                               +
         |                                                               |
         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      

      See RFC2460 for more details on IPv6.

  • UDP: user datagram protocol
    • The User Datagram Protocol is used to send short messages between devices. It exists in the Transport Layer, which is used to direct data from applications to the network and vice-versa. Applications that want to send data through the network must be assigned a port number that can be used to address the application. The UDP header is appended to an IP header. The structure of a UDP packet is:

                        0      7 8     15 16    23 24    31  
                       +--------+--------+--------+--------+ 
                       |     Source      |   Destination   | 
                       |      Port       |      Port       | 
                       +--------+--------+--------+--------+ 
                       |                 |                 | 
                       |     Length      |    Checksum     | 
                       +--------+--------+--------+--------+ 
                       |                                     
                       |          data octets ...            
                       +---------------- ...                 
      
      

      UDP does not guarantee the delivery of all packets, and it may sometimes receive data packets out of order. While this may sound like a disadvantage, UDP is ideal for applications where the data must be transmitted very quickly, because its packet structure is simple and it provides minimal overhead when sending data in the transport layer.

      See RFC768 for more details on UDP.

  • TCP: transmission control protocol
    • TCP is another Transport Layer protocol. It differs from UDP because it is designed to send a stream of data, not just a single packet. Basically, TCP takes a big chunk of data, splits it into packets, and then sends them. It verifies that every packet is delivered to the destination, and assembles the packets in order when they are received. For small messages (i.e. only one packet) TCP is a lot of overhead.

      See RFC793 for more details on TCP.

  • SLIP: serial line internet protocol
    • Serial Line Internet Protocol is an implementation of the internet protocol designed to work over serial ports and dial-up modems. It is not often used for internet connections anymore, however, it is still commonly used with microprocessors because it is a simple way to encapsulate IP packets. It takes IP packets and just frames them with a start and end characters (if any characters in the IP packet match the start or end characters, they are escaped).

      See RFC1055 for more details on SLIP.