HTTP over TCP/IP

TCP/IP or Transmission Control Protocol/Internet Protocol is the basic communication language or protocol of the Internet. It is a set of transport and network-layer protocols for machines to communicate with each other over the network. On the other hand HTTP is a client-server application-level protocol, which typically runs over a TCP/IP connection, as illustrated.

Internet Protocol is a network-layer protocol, deals with network addressing and routing. In an IP network, each machine is assigned an unique IP address, for example 192.168.0.1, and the IP software is responsible for routing a message from the source IP to the destination IP. In IPv4 (IP version 4), the IP address consists of 4 bytes, each ranges from 0 to 255, separated by dots, which is called a quad-dotted form. Since memorizing number is difficult for most of the people, an english-like domain name, such as www.mywebsite.com is used instead.  The DNS (Domain Name Service) translates the domain name into the IP address (via distributed lookup tables). A special IP address 127.0.0.1 always refers to your own machine.  It's domain name is "localhost" and can be used for local loopback testing.

Transmission Control Protocol is a transport-layer protocol, responsible for establish a connection between two machines. TCP consists of 2 protocols: TCP and UDP (User Datagram Package). TCP is reliable, each packet has a sequence number, and an acknowledgement is expected. A packet will be re-transmitted if it is not received by the receiver. Packet delivery is guaranteed in TCP.  UDP does not guarantee packet delivery, and is therefore not reliable.  However, UDP has less network overhead and can be used for applications such as video and audio streaming, where reliability is not critical.

TCP multiplexes applications within an IP machine. For each IP machine, TCP supports (multiplexes) up to 65536 ports (or sockets), from port number 0 to 65535.  An application, such as HTTP or FTP, runs (or listens) at a particular port number for incoming requests. Port 0 to 1023 are pre-assigned to popular protocols, e.g., HTTP at 80, FTP at 21, Telnet at 23, SMTP at 25, NNTP at 119, and DNS at 53.  Port 1024 and above are available to the users.

Although TCP port 80 is pre-assigned to HTTP, as the default HTTP port number, this does not prohibit you from running an HTTP server at other user-assigned port number (1024-65535) such as 8000, 8080, especially for test server. You could also run multiple HTTP servers in the same machine on different port numbers.

When a client issues a URL without explicitly stating the port number, for example http://www.mywebsite.com/index.html, the browser will connect to the default port number 80 of the host www.mywebsite.com. You need to explicitly specify the port number in the URL, e.g. http://www.mywebsite.com:8000/index.html if the server is listening at port 8000 and not the default port 80.

In brief, to communicate over TCP/IP, you need to know
  • IP address or hostname
  • Port number



Next Topic :

No comments:

Post a Comment