3.1. Networking Review

3.1.1. Protocols

A protocol is a set of rules that determine how communication between two parties is achieved.

Both machines and people use protocols to communicate.

  • Physical layer protocols for human communication include:

    1. One person’s vocal cords produces sound waves, which generate vibrations in the ear drum of another person.
    2. One person writes on paper while another person reads the writing from the paper.
    3. One person uses his hands to make set shapes and movement patterns, while another person views the sign language with his eyes.
  • Language layer protocols include: English, French, Spanish ...

Multiple protocols are often used together in layers. In the example of human communication, we use both a physical layer and a language layer together.

Protocols may be replaced as long as the new protocol fills the same role. For example, I use English to speak with my friends, but other people may prefer to use Spanish or some other language. The physical layer may be the same, but different functionally equivalent languages may be used.

3.1.2. Networking Protocols

Common networking protocols include:

Layer Protocol
Physical CAT 5/6 cables, fiber optics, Wireless 802.11
Data Link Ethernet
Routing IP
Transport / Session TCP, UDP
Application HTTP, SMTP, FTP, ...

Depicted above are protocols commonly used with TCP/IP. We may substitute TCP for UDP or use different application layer protocols.

We will not concern ourselves at all with the physical or data link layers, which are implemented with hardware components. Our primary concern for this class is at the application layer. So we are concerned with application layer protocols and the hand-off mechanism to and from TCP/IP, which is the socket.

3.1.3. Transmission Control Protocol/Internet Protocol (TCP/IP)

TCP/IP is not one protocol, but a suite of small, specialized protocols called sub-protocols.

3.1.3.1. Internet Protocol (IP)

  • IP directs the networking packets through the routers from the source computer to the destination computer.
  • The IP portion of each TCP/IP frame acts as an envelope for the TCP/IP data.
../_images/ip_header.png

The IP header contains information necessary for routers to transfer data between subnets.

3.1.3.2. Transport Control Protocol (TCP)

  • TCP provides reliable end to end communication.
  • It includes error correcting transport and session management facilities.

3.1.3.3. User Datagram Protocol (UDP)

  • UDP is an alternative protocol to TCP.
  • The UDP transport service is connectionless with no error correction. There are only four fields in UDP header compared to 10 in the TCP header.
  • UDP is considered unreliable.
  • UDP is used for broadcast applications and video / audio data streaming. For video and audio streaming, speed is more important than reliability.
  • In the past, it has been used as part of larger application layer protocols for DNS and file sharing with the Unix Network File System. TCP is now used exclusively for most applications.
  • We will not use UDP for projects in this class. The choice of TCP or UDP for network programming, is just changing a socket parameter. Network programming is mostly concerned with the application layer.

3.1.4. What about Sockets and Ports?

So far, this has been a review of Networking 1 materiel. Now we turn our attention to the basic concepts of writing network applications. The TCP/IP protocol suite is implemented in the computer’s operating system. Ports and sockets are both abstract resources (not hardware) provided by the operating system to facilitate passing data between the operating system and application programs.

Note

Once we understand how to work with ports and sockets, we will turn our attention to application layer protocols and rely on other software to even handle the socket level communication.

Summary:

  • The IP protocol is the lowest level protocol of concern to us. It handles moving the data to the right computer.
  • At the source computer and destination computer, the TCP protocol is used to establish connections and do error correction.
  • TCP gets data from and delivers data to an application program. But there may be many application programs running on the computer. This is where the port and associated port number comes into play.

The TCP protocol picks up and deposits the data at a port, which is a numbered, buffered storage container provided by the operating system as the hand-off point between TCP and the application program.

../_images/TCP_header.png

The TCP Headers hold the port numbers used by the source and destination applications.

A port can be viewed as a rendezvous point between TCP and the application. However, the port is a part of the operating system and the application program can not directly access the port. This is where the socket comes into play.

This is similar to how the Postal Service uses mailboxes as rendezvous points.

../_images/mail-boxes.jpg

Mailboxes are a rendezvous point between the postal carrier and the customer.

As an analogy, think of TCP/IP as the Postal Service. They pick up and leave mail in your mailbox, which is similar to a port. People who live in rural areas are always looking for friends, who might be traveling past the mailboxes, to shuttle their mail. A friend who carries a letter to your mailbox and delivers any mail waiting in your mailbox to you, is performing the same service that a socket does in relation to the application program and the port.

  • A socket is a tool that carries data back and forth between a port and an application program, thus allowing the application to read from and write to the port, which in turns equates to sending and receiving data to and from the remote computer.
  • A socket is an abstract resource of the operating system, which processes may request. We use the term abstract because it is not a piece of hardware. It consists of some data structures and instructions inside the operating system kernel.

Summary:

  • TCP puts the data in the right port (mail box).
  • The socket transports the data between the port (mail box) and the application.