|
This article will attempt to explain what happens on a network when you click a link. It assumes that you're using an ethernet lan and the tcp/ip protocol suite. This is a very high level introduction to networking with links to provide more information.
First your computer needs to know a few things. The ip address and netmask are used to differentiate between local and remote ip addresses. There must be an address that's used to access remote sites, that address is the default gateway. Since tcp/ip uses address numbers and humans remember names there has to be a way to convert domain names to addresses, these are known as name servers or DNS servers. Subnets identify what addresses are local. They do this by comparing your IP address and subnet mask with the ip address of the host you're connecting to. A subnet mask is a series of 1's generally followed by a series of 0's when represented in binary math. If the portion of the destination IP address that is under the 1's is the same as your ip address then the host is on your network. Most home networks have a default gateway as the only way out. Computers on corporate networks can have multiple gateways, router 1 for accounting, router 2 for engineering and router 3 for everywhere else. This information is stored on each computer in the routing table. The last bit of information needed is at least one Domain name server (DNS server). These servers convert names (URI's/ URL's) like http://www.millfam.org/ into ip addresses (currently 72.29.87.197). Now that we have all the information required to get data to the nic a brief description of the OSI model is required to understand what happens on the lan. The model was developed to separate responsibilities and improve interoperability of components. Most lans use ethernet as the layer 2 protocol and TCP/IP at layers 3 and 4. Layer 1 is the physical network. Ethernet frames can be sent over coaxial cable, fiber optic cable, twisted pair cable, which is probably the most common method or over a wireless radio. The method of data transmission makes no difference to the layers above it. Layer 2 is the data link layer, and in this article is considered to be ethernet. It's usually combined with layer one in your nic. This layer adds its own header and sends out a frame to the physical layer. Each networked device will have its own MAC address and every device on the local lan will communitcate with each other using that address. Layer 3 is the network layer and in this article will be IP. This layer uses IP addresses to intercommunicate. The IP addresses will remain intact for the entire trip unless address translation occurs. This layer adds a header and sends a packet to or receives a packet from the data link layer. Layer 4 is the transport layer. The transport layer is responsible for the reliability of communication between two hosts. At this layer tcp/ip data is known as a datagram and two protocols are used, TCP provides the slow but reliable connections, UDP provides a faster but less reliable connection. Enough background, now what happens when you click that link? Let's assume you clicked http://www.millfam.org/. Your computer needs to convert that name into an address, so it wants to send out a UDP query to the name server. The address of the name server will be compared to your address to see if it's local or remote. Let's assume it's local. Your computer still doesn't know the mac address so it uses ARP to convert local IP addresses into physical addresses. Your computer then adds an ethernet frame header with the physical address of the server to the DNS request an puts it out on the lan. Since DNS requests are UDP your computer waits a while to see if it gets a reply. You may notice "looking up www.millfam.org" in your browser's status bar while waiting for a reply. When it gets the reply with the ip address your computer can send out the actual web page request. The server probably isn't on the lan so you can't directly connect to it. Your computer must forward the web page request to the gateway for routing. The MAC address of the gateway if not known must now be looked up using ARP. Since http (web browsing) uses TCP which is connection oriented the server and your computer must complete a "3 way handshake" before any data can be transferred. Your computer will send out a "Syn" request to the server, note that although the server's IP address is in the packet, the ethernet frame has the MAC address of your default gateway. The server then replies with a "Syn-Ack" packet back to your computer. Your computer responds with a "Fin" packet, which completes the handshake. Now you can send the request for the web page using information obtained during the handshake. The server will respond with an amount of data negotiated during the handshake and wait for an "Ack" packet from your computer indicating that all of the sent data was received. If it doesn't receive this packet the server will resend the data. The lifespan of a tcp connection can be seen in this diagram. Newer versions of HTTP allow for all the items on the web page from this server to be downloaded using one handshake. If items on the page (ads, pictures, etc.) come from different servers then your computer will have to negotiate the hand shake with each server. Once your computer has received all of the data it can request to close the connection with a "Fin" packet. The server responds with an "Ack" and then a "Fin" packet or a "Fin-Ack" packet combining the two packets into one. Your computer then responds with an "Ack" packet and the connection is closed. Key Points: Lan communication is sent directly using MAC addresses. Traffic destined outside the lan is sent to the gateway using the remote IP address, but the gateway's IP address. Arp is used to convert IP addresses to physical MAC addresses. DNS is used to convert domain names into IP addresses. TCP is used when data transfer must be reliable and complete. UDP is used when the data transfer must be fast and lightweight. For example the wait for voice or video data to be resent would be more noticeable than the occasional missed or out of order packet. UDP is also used when a single server must handle a lot of small requests quickly as in DNS since the lack of connection establishment speeds things up.
|