The layered concept of networking was developed to accommodate changes in technology. Each layer of a specific network model may be responsible for a different function of the network. Each layer will pass information up and down to the next subsequent layer as data is processed.
The OSI Network Model Standard
The OSI network model layers are arranged here from the lower levels starting with the physical (hardware) to the higher levels.
- Physical Layer - The actual hardware.
- Data Link Layer - Data transfer method (802x ethernet). Puts data in frames and ensures error free transmission. Also controls the timing of the network transmission. Adds frame type, address, and error control information. IEEE divided this layer into the two following sublayers.
- Logical Link control (LLC) - Maintains the Link between two computers by establishing Service Access Points (SAPs) which are a series of interface points. IEEE 802.2.
- Media Access Control (MAC) - Used to coordinate the sending of data between computers. The 802.3, 4, 5, and 12 standards apply to this layer. If you hear someone talking about the MAC address of a network card, they are referring to the hardware address of the card.
- Network Layer - IP network protocol. Routes messages using the best path available.
- Transport Layer - TCP, UDP. Ensures properly sequenced and error free transmission.
- Session Layer - The user's interface to the network. Determines when the session is begun or opened, how long it is used, and when it is closed. Controls the transmission of data during the session. Supports security and name lookup enabling computers to locate each other.
- Presentation Layer - ASCII or EBCDEC data syntax. Makes the type of data transparent to the layers around it. Used to translate date to computer specific format such as byte ordering. It may include compression. It prepares the data, either for the network or the application depending on the direction it is going.
- Application Layer - Provides services software applications need. Provides the ability for user applications to interact with the network.
Many protocol stacks overlap the borders of the seven layer model by operating at multiple layers of the model. File Transport Protocol (FTP) and telnet both work at the application, presentation, and the session layers.
The Internet, TCP/IP, DOD Model
This model is sometimes called the DOD model since it was designed for the department of defense It is also called the TCP/IP four layer protocol, or the internet protocol. It has the following layers:
Please note the four layer TCP/IP protocol. Each layer has a set of data that it generates.
- Link - Device driver and interface card which maps to the data link and physical layer of the OSI model.
- Network - Corresponds to the network layer of the OSI model and includes the IP, ICMP, and IGMP protocols.
- Transport - Corresponds to the transport layer and includes the TCP and UDP protocols.
- Application - Corresponds to the OSI Session, Presentation and Application layers and includes FTP, Telnet, ping, Rlogin, rsh, TFTP, SMTP, SNMP, DNS, your program, etc.
- The Link layer corresponds to the hardware, including the device driver and interface card. The link layer has data packets associated with it depending on the type of network being used such as ARCnet, Token ring or ethernet. In our case, we will be talking about ethernet.
- The network layer manages the movement of packets around the network and includes IP, ICMP, and IGMP. It is responsible for making sure that packages reach their destinations, and if they don't, reporting errors.
- The transport layer is the mechanism used for two computers to exchange data with regards to software. The two types of protocols that are the transport mechanisms are TCP and UDP. There are also other types of protocols for systems other than TCP/IP but we will talk about TCP and UDP in this document.
- The application layer refers to networking protocols that are used to support various services such as FTP, Telnet, BOOTP, etc. Note here to avoid confusion, that the application layer is generally referring to protocols such as FTP, telnet, ping, and other programs designed for specific purposes which are governed by a specific set of protocols defined with RFC's (request for comments). However a program that you may write can define its own data structure to send between your client and server program so long as the program you run on both the client and server machine understand your protocol. For example when your program opens a socket to another machine, it is using TCP protocol, but the data you send depends on how you structure it.
Data Encapsulation, a Critical concept to be understood
When starting with protocols that work at the upper layers of the network models, each set of data is wrapped inside the next lower layer protocol, similar to wrapping letters inside an envelope. The application creates the data, then the transport layer wraps that data inside its format, then the network layer wraps the data, and finally the link (ethernet) layer encapsulates the data and transmits it.
Each network layer either encapsulates the data stream with additional information, or manages data handling or come part of the connection.
Without going into a great deal of technical detail, I will describe a general example of how these layers work in real life. Assuming that the protocol stack being used is TCP/IP and the user is going to use an FTP client program to get or send files from/to a FTP server the following will essentially happen:
- The user will start the FTP client program on the sending computer.
- The user will select the address (If the user selected a name, a description of DNS would need to be described complicating this scenario) and port of the server.
- The user will indicate to the FTP client program that they want to connect to the server.
- The application layer will send information through the presentation layer to the session layer telling it to open a connection to the other computer at a specific address and port. The presentation layer will not do much at this time, and the presentation layer is actually handled by the FTP program.
- The session layer will negociate through to the FTP server for a connection. There are several synchronization signals sent between the client and server computers just to establish the connection. This is a description of the sending of a signal from the client to the server:
- The session layer of the client will send a data packet (SYN) signal to the transport layer.
- The transport layer will add a header (TCP header) to the packet indicating what the source port is and what the destination port is. There are also some other flags and information that will not be discussed here to minimize complexity of this explanation.
- The network layer will add source IP address and destination IP address along with other information in a IP header.
- The datalink layer will determine (using ARP and routing information which is not discussed here for brevity) the hardware address of the computer the data is being sent to. An additional header (ethernet) will be added at this layer which indicates the hardware address to receive the message along with other information.
- The information will be transmitted across the physical wire (hardware layer) until the signal reaches the network card of the server computer. The signal may go through several hubs or repeaters.
- The FTP server will normally only look for ethernet frames that are matching its own hardware address.
- The FTP server will see the ethernet frame matching its address and strip the ethernet header information and send it to the network layer.
- The network layer will examine the IP address information, strip the IP header, and if the IP address matches its own, will send the information to the transport layer.
- The transport layer will look at the TCP port number and based on the port number and services being run, will strip the TCP header and send the information to the appropriate program which is servicing the requested port.
- At this point, the session layer in the FTP program will conduct a series of data exchanges between itself through all the lower layers to the client computer until a session is established.
- At this point information may be sent through several FTP commands between the client and the server. Every transmission passes through the network layers from the application layer down to the hardware layer and back up the layers on the receiving computer.
- When the client decides to terminate the session layer will be informed by the higher layers and will negociate for the closing of the connection.