Wednesday, October 31, 2012

Network Protocols

we shall look into the functionality and purpose of the protocols of the TCP/IP suite in the following order:
  • Basic Protocols
  • Internet Protocols
  • E-mail Protocols
  • Other Protocols

    Basic Protocols

    As we can see, the TCP/IP protocol suite has a much simpler layered structure than the seven layers of the OSI model. The Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) protocols are transport protocols corresponding to OSI layer 4. Both protocols make use of the Internet Protocol (IP), an OSI layer 3 protocol (the network layer). As well as these three protocols, there are two more basic protocols in the TCP/IP suite that extend the IP protocol: ICMP and IGMP. The functionality of these protocols must be implemented in the layer housing the IP protocol, hence they are shown in that layer in the preceding figure.

    IP-Internet Protocol

    The Internet Protocol connects two nodes. Each node is identified by a 32-bit address, called its IP address. When sending a message, the IP protocol receives the message from upper level protocols such as TCP or UDP and adds the IP header which contains information about the destination host.
    Subnets
    Connecting two nodes of different networks requires a router. The host number is defined by 24 bits of a Class A IP address; while with a Class C network, just 8 bits are available. A router splits the host number into a subnet number and host number. Adding additional routers will reduce broadcasts in the network, which can reduce network load. The main reason for adding routers is to improve connectivity between sites in different buildings, cities, and so on.

    Transport Layer-Port Numbers

    The IP protocol uses IP addresses to identify nodes on the network, while the transport layer (layer 4) uses endpoints to identify applications. TCP and UDP protocols use a port number together with an IP address to specify an application endpoint.
    The server must supply a known endpoint for a client to connect to, although the port number can be created dynamically for the client.
    TCP and UDP port numbers are 16 bits, and can be divided into three categories:
    • System (Well-Known) Port Numbers
    • User (Registered) Port Numbers
    • Dynamic or Private Ports

      TCP-Transmission Control Protocol

      Connection-oriented communication can use reliable communication where the layer 4 protocol sends acknowledgements of data receipts, and requests retransmission if data is not received or is corrupted. The TCP protocol uses such reliable communication.
      Some of the application protocols that use TCP are HTTP, FTP, SMTP, and Telnet.
      TCP requires that a connection must be opened before data can be sent. The server application must perform a so-called passive open to create a connection with a known port number, where rather than making a call to the network, the server listens and waits for incoming requests. The client application must perform an active open by sending a synchronize sequence number (SYN) to the server application to identify the connection. The client application can use a dynamic port number as a local port. The server must send an acknowledgement (ACK) to the client together with the sequence number (SYN) of the server. The client in turn answers with an ACK, and the connection is established.

      UDP-User Datagram Protocol

      Contrary to TCP, UDP is a very fast protocol as it specifies just the minimum mechanism required for data transfer. Of course this has some disadvantages. Messages can be received in any order, and a message that was sent first could be received last. The delivery of UDP messages is not guaranteed at all, and messages can be lost, or even two copies of the same message might be received. This latter scenario can happen when two different routes are used to send the message to the same destination.
      UDP does not require a connection to be opened, and data can be sent as soon as it is ready. UDP doesn't send acknowledgement messages, so the data can be received, or it can be lost. If reliable data transfer is needed over UDP, it must be implemented in a higher-level protocol.
      So what are the advantages of UDP, why would we want to use an unreliable protocol such as this? To understand the most important reason for using UDP, we have to differentiate between unicast, broadcast, and multicast communications.

      ICMP-Internet Control Message Protocol

      ICMP is a control protocol used by IP devices to inform other IP devices of activity and errors in the network. Without TCP, IP is not a reliable protocol, and there are no acknowledgements, no error control for data (only a header checksum), and no retransmissions.
      Errors detected may be reported with ICMP messages. The ICMP messages are used to send feedback about the status of the network. For example, a router sends an ICMP 'destination unreachable' message if a suitable entry for a network cannot be found in a routing table. A router can also send an ICMP 'redirect' message if a better path was found.

      IGMP-Internet Group Management Protocol

      Similarly to ICMP, IGMP is an extension to the IP protocol and must be implemented by the IP module. IGMP is used by multicasting applications. When sending a broadcast message to a complete LAN, every node in the LAN analyzes the message up to the transport layer to verify if some application wants to receive messages from the port of the broadcast. If no application is listening, the message is destroyed and does not progress beyond the transport layer. This does mean that some CPU cycles are needed by every host no matter if the broadcast message is of interest or not.
      Multicasts address this concern, by only sending messages to a group of nodes rather than every node in the LAN. The network interface card can detect if the system is interested in a particular message by analyzing the broadcast MAC address without needing the assistance of the CPU.


      Internet Protocols

      After discussing base protocols, we can now step up to a higher level. The HTTP and FTP protocols cover layers 5-7 of the OSI model.

      FTP-File Transfer Protocol

      FTP is used to copy files from and to a server, and to list files and directories on a server. It is an application level protocol based on TCP, where FTP commands are encapsulated within the TCP data block of a TCP message.
      An application model with an FTP server and client is illustrated in the picture below. The client application presents a user interface and creates an FTP request according to the user's request and the FTP specification. The FTP command is sent to the server application over TCP/IP, and the FTP interpreter on the server interprets the FTP command accordingly. Depending on the FTP command, a list of files or a file from the server's file system is returned to the client in an FTP reply.

      HTTP-Hypertext Transfer Protocol

      HTTP is the main protocol used by web applications. Similar to the FTP protocol, HTTP is a reliable protocol that is achieved by using TCP. Like FTP, HTTP is also used to transfer files across the network. Unlike FTP, it has features such as caching, identification of the client application, support for different attachments with a MIME format, and so on. These features are enabled within the HTTP header.
      To demonstrate what an Internet browser is doing when it requests files from a web server, we can use the telnet application to simulate a browser. Start the telnet application by entering telnet in the Run dialog of the Start menu, and we see the Microsoft Telnet> prompt. Enter set local_echo (set localecho with Windows XP) to display the entered commands locally for demonstration purposes. If we don't set this option, commands we send to the server would not be displayed by the telnet application. Now we can connect to the web server with the open command. The command open msdn.microsoft.com 80 creates a TCP connection to port 80 of the server at msdn.microsoft.com. The telnet application uses port 23 by default, hence we have to specify a port for the HTTP request. The default port of a web server offering HTTP services is port 80.

      HTTPS-HTTP over SSL (Secure Socket Layer)

      If there is a requirement to exchange confidential data with a web server, HTTPS can be used. HTTPS is an extension to the HTTP protocol, and the principles discussed in the last section still apply. However, the underlying mechanism is different, as HTTPS uses SSL (Secure Socket Layer), originally developed by Netscape. SSL sits on top of TCP and secures network communication using a public/private key principle to exchange secret symmetric keys, and a symmetric key to encrypt the messages.
      To support HTTPS, the web server must install a certificate so that it can be identified. The default port for HTTPS requests is 443.

      E-Mail Protocols

      There are quite a few protocols for use with e-mail. In this section, I'll try to provide an overview of the most important mail-related protocols. In Chapter 9, we will look into these more, and see how to create applications that use them.

      SMTP-Simple Mail Transfer Protocol

      SMTP is a protocol for sending and receiving e-mail messages. It can be used to send e-mail between a client and server that both use the same transport protocol, or to send e-mail between servers that use different transport protocols. SMTP has the capability to relay messages across transport service environments. SMTP does not allow us to read messages from a mail server, however, and for this activity POP3 or IMAP protocols should be used.
      An SMTP service forms part of the Internet Information Server installation of Windows 2000 and XP.
      The SMTP standard is defined with RFC 821; the SMTP message format is defined with RFC 822.

      POP3-Post Office Protocol

      The Post Office Protocol was designed for disconnected environments. In small environments it is not practical to maintain a persistent connection with the mail server, for instance, in environments where the connection time must be paid. With POP3 the client can access the server and retrieve the messages that the server is holding for it. When messages are retrieved from the client, they are typically deleted on the server, although this is not necessarily the case.
      Windows .NET Server includes a POP3 server.
      POP 3 is defined by RFC 1081.

      IMAP-Internet Message Access Protocol

      Like POP3, IMAP is designed to access mails on a mail server. Similar to POP3 clients, an IMAP client can have an offline mode where mails can be manipulated on the local machine. Unlike POP3 clients, IMAP clients have greater capabilities when in online mode, such as retrieving just the headers or bodies of specified mails, searching for particular messages on the server, and setting flags such as a replied flag. Essentially, IMAP allows the client to manipulate a remote mailbox as if it was local.
      IMAP is defined with RFC 1730.

      NNTP-Network News Transfer Protocol

      Network News Transfer Protocol is an application layer protocol for submitting, relaying, and retrieving messages that form part of newsgroup discussions. This protocol provides client applications with access to a news server to retrieve selected messages, and also supports server to server transfer of messages.
      NNTP is defined by the RFCs 850, 977, and 1036.











No comments:

Post a Comment