Showing posts with label tcp. Show all posts
Showing posts with label tcp. Show all posts

Tuesday, January 26, 2010

TCP/IP Application Layer

Arguably, the most popular TCP/IP application today is the web browser. Many major software vendors either have already changed or are changing their software to support access from a web browser. And thankfully, using a web browser is easy–you start a web browser on your computer and select a web site by typing in the name of the web site, and the web page appears.

What really happens to allow that web page to appear on your web browser? These next few sections take a high-level look at what happens behind the scene.

Imagine that Bob opens his browser. His browser has been configured to automatically ask for web server Larry’s default web page, or home page. The general logic looks like that in Figure 2-1.


Figure 2-1 Basic Application Logic to Get a Web Page

So what really happened? Bob’s initial request actually asks Larry to send his home page back to Bob. Larry’s web server software has been configured to know that Larry’s default web page is contained in a file called home.htm. Bob receives the file from Larry and displays the contents of the file in the web browser window.

Taking a closer look, this example uses two TCP/IP application layer protocols. First, the request for the file and the actual transfer of the file are performed according to the Hypertext Transfer Protocol (HTTP). Many of you have probably noticed that most web sites’ URLs (Universal Resource Locators, the text that identifies a web server and a particular web page) begin with the letters “http,” to imply that HTTP will be used to transfer the web pages.

The other protocol used is the Hypertext Markup Language (HTML). HTML defines how Bob’s web browser should interpret the text inside the file he just received. For instance, the file might contain directions about making certain text be a certain size, color, and so on. In most cases, it also includes directions about other files that Bob’s web browser should get things such as graphics images and animation. HTTP would then be used to get those additional files from Larry, the web server.

A closer look at how Bob and Larry cooperate in this example reveals some details about how networking protocols work. Consider Figure 2-2, which simply revises Figure 2-1, showing the locations of HTTP headers and data.


Figure 2-2 HTTP Get Request and HTTP Reply

To get the web page from Larry, Bob sends something called an HTTP header to Larry. This header includes the command to “get” a file. The request typically contains the name of the file (home.htm in this case), or, if no filename is mentioned, the web server assumes that Bob wants the default web page.

The response from Larry includes an HTTP header as well, with something as simple as “OK” returned in the header. In reality, it includes an HTTP return code. For instance, if you have ever used the web, and a web page that you looked for was not found, then you received an HTTP 404 “not found” error, which means that you received an HTTP return code of 404. When the requested file is found, the return code is 0, meaning that the request is being processed.

This simple example between Bob and Larry introduces one of the most important general concepts behind networking models: When a particular layer wants to communicate with the same layer on another computer, the two computers use headers to hold the information that they want to communicate. The headers are part of what is transmitted between the two computers. This process is called same-layer interaction.

The application layer protocol (HTTP, in this case) on Bob is communicating with Larry’s application layer. They each do so by creating and sending application layer headers to each other–sometimes with application data following the header and sometimes not, as seen in Figure 2-2. Regardless of what the application layer protocol happens to be, they all use the same general concept of communicating with the same layer on the other computer using application layer headers.

TCP/IP application layer protocols provide services to the application software running on a computer. The application layer does not define the application itself, but rather it defines services that applications need–like the ability to transfer a file in the case of HTTP. In short, the application layer provides an interface between software running on a computer and the network itself.

TCP/IP Internetwork Layer

Imagine that you just wrote a letter to your favorite person on the other side of the country and that you also wrote a letter to someone on the other side of town. It’s time to send the letters. Is there much difference in how you treat each letter? Not really. You put different addresses on the envelope for each letter because the letters need to go to two different places. You put stamps on both letters and put them in the same mailbox. The postal service takes care of all the details of figuring out how to get each letter to the right place whether it is across town or across the country.

Inside the postal service, both letters are processed. One letter gets sent to another post office, then another, and so on, until the letter gets delivered across the country. The local letter might go to the post office in your town and then simply be delivered to your friend across town, without going to another post office.

So what does this all matter to networking? Well, the internetwork layer of the TCP/IP networking model, the Internet Protocol (IP), works much like the postal service. IP defines addresses so that each host computer can have a different IP address, just like the postal service defines addressing that allows unique addresses for each house, apartment, and business. Similarly, IP defines the process of routing so that devices called routers (ingenious name, huh?) can choose where to send packets of data so that they are delivered to the correct destination. Just like the postal service created the necessary post offices, sorting machines, trucks, and personnel to deliver the mail, the internetwork layer defines much of the details needed to implement the necessary networking infrastructure.

Chapter 5, Fundamentals of IP, describes the TCP/IP Internetwork layer further, with other details scattered throughout the book. But to help you understand the basics of the internetwork layer, take a look at Bob’s request for Larry’s home page, now with some information about IP, in Figure 2-4.

First, some basic information about the figure will help. The LAN cabling details are not important for this example, so both LANs simply are represented by the lines shown near Bob and Larry, respectively. When Bob sends the data, he is sending an IP packet, which includes the IP header, the transport layer header (TCP, in this example), the application header (HTTP, in this case), and any application data (none, in this case). The IP header includes both a source and a destination IP address field, with Larry’s IP address as the destination address and Bob’s as the source.


Figure 2-4 IP Services Provided to TCP

Bob sends the packet to R2, which makes a routing decision. R2 chooses to send the packet to R1 because the destination address of the packet is 1.1.1.1, and R1 knows enough about the network topology to know that 1.1.1.1 (Larry) is on the other side of R1. Similarly, when R1 gets the packet, it forwards the packet over the Ethernet to Larry. And if the link between R2 and R1 fails, IP allows R2 to learn of the alternate route through R3 to reach 1.1.1.1.

IP defines logical addresses, called IP addresses, that allow each TCP/IP speaking device (called IP hosts) to communicate. It also defines routing the process of how a router should forward, or route, packets of data. Other protocol specifications, like OSI, have different protocols that also define addressing and routing.