The Basics

From CLUG Wiki

Jump to: navigation, search

Well, after I started writing the Iptables / Netfilter page User:Cayle asked whether I couldn't better explain the concepts behind networking. So i'll try to give an easy introduction to Networking and specificaly Networking under Linux with TCP/IP.


Contents

TCP/IP Basics

TCP/IP stands for Transmission Control Protocol over Internet Protocol. TCP/IP is the mainstay of Internet communications and also for many other networks, whether they be in use at SOHO's or large interconnected Wide Area Networks.


The OSI Network Model

IP and all other protocols in use on the internet (and in most other networks) are designed around the Open Systems Interconnect model.

Specificaly, the OSI model consits of 7 Layers of Protocols. Each layer has the property that it can access the specific functions of the Layer(s) underneath it.

The 7 Layer OSI Model Looks like this

Application 7
Presentation 6
Session 5
Transport 4
Network 3
Link 2
Physical 1

If this all sounds confusing right now, don't worry. All shall be revealed :)


The physical layer

As you can see, the physical layer is the bottom most layer in the OSI model.

The physical layer reperents the electrical and hardware aspect of the connection. For example, your Network Card, UTP Cable and Modem are all devices which form part of the physical network layer.


The Link Layer

The second layer in the OSI model is the Link layer.

The link layer's job is to provide a means to transmit and recieve data. It can also possible correct and detect errors that ocur on the physical layer.

Addressing is possible on the link layer in the form of Media Access Control Addresses (MAC addresses) This is a physical addressing scheme, and these addresses are physically hard coded into the specific network appliance.

Network switches operate on this layer.

Ethernet is a protocol that operate on this level.


The Network Layer

Now it starts to get interresting. The Network layer is responsible for providing a means to send data of varying size between hosts or networks relativly reliably. It has to be able to perform routing between different hosts and networks and also support a means for network segmentation (division). It should also support the Quality of service requested by the layer above it.

The Internet Protocol is the best example of this.

Routers operate on this level.


The Transport Layer

The transport layer's job is to provide a mechanism for reliable sending data using the layers below it. It should before error checking, and also check the status of the Network Layer and asure that a reliable link is available.

Transmission Control Protocol (or TCP) is sits on the Transport Layer


The Session, Presentation and Application Layers

The session, Presentation and application layers are are almost always managed by pieces of software manipulating the data and information that it sends or recieves via the protocol sitting on the transport layer.


The Session Layer provides a method for communication between the end-user applications on the different hosts. It is responsible for establishing and terminating said network communication processes between hosts.

The Presentation layer (Also software) is in charge of syntactcal compatibilty between the data an application expects, that which it recieves and vice versa.

Many a times this involves decoding, encrypting, decrypting and compression of data supplied by the user (or software).


Application layer protocols facilitate the communication between different software packages and the lower laying network layers. This ensures that the network can understand the Application (or Users) request, and communicate with relavant hosts (requested by the Application or user) and establish communication making use of a standardised protocol.

SMTP (Mail Sending), POP (Mail Recieving) , HTTP (Web) and HTTPS are examples of application layer protocols.


Protocols

Google defines a protocol as follows:

The 'language' spoken between computers to help them exchange information. More technically, it is a formal description of message formats and the rules that two computers must follow in order to exchange those messages.

As the definition states, a protocol is nothing but a standardised definition of a set of rules that all parties that are involved with a particular communication instance have to follow. It ensures compatibility with different systems.


The Internet Protocol

The Internet Protocol is the set of "rules" that ensure that communication over the Internet follows a standard form.

More formaly according to WikiPedia:

The Internet Protocol (IP) is a data-oriented protocol used by source and destination hosts for communicating data across a packet-switched internetwork.

Data is sent between used in chunks called "packets"

Each packet contains information about where it should go, where it came. This allows special Network devices called "Routers" to route a packet to where it should go.

IP itself doesn't provide a fantastic way to send actual data between different machines on a network, but it DOES provide a great way for the communication it self to be established between the hosts.

IP is a Network protocol, meaning that it handles packet routing between different hosts on the network.


Transmission Control Protocol over Internet Protocol (TCP/IP)

TCP is a transport layer protocol. It sits on level 4 of the OSI network model.

From wikipedia:

The Transmission Control Protocol (TCP) is one of the core protocols of the Internet protocol suite. Using TCP, applications on networked hosts can create connections to one another, over which they can exchange data or packets. The protocol guarantees reliable and in-order delivery of sender to receiver data. TCP also distinguishes data for multiple, concurrent applications (e.g. Web server and email server) running on the same host.


TCP also makes use of the idea of a port.

If a host on a network can be visualised as a house, then a port will be every door and window that grants access to the house. You can imagine that at every door (or window) there is someone waiting to serve you. This is basicaly a port. A specific place on a host where a certain service can be accessed.


Going into TCP/IP in more detail will REALLY not be the basics any more, so, check out this link to a WikiPedia article on TCP/IP HERE


User Datagram Protocol

UDP is much like the TCP protocol in that it sites on the transport layer and provides 'n means to transfer data between hosts. However, where TCP was designed to ensure reliability and order, UDP was designed to be a fast and efficient protocol for small packets (datagrams for UDP) of information. Since UDP is not a statefull protocol like TCP, datagrams may arrive out of order, or even not at all. The TCP protocol would take measures to ensure that do arrive and are handled in the order they where sent. UDP leaves such task's up to the software running in the layers above it.

More information on how udp works can be found HERE


Internet Control Message Protocol

ICMP is also a layer 4 protocol. It was designed primarily as a diagnostics protocol to determine the status of hosts and networks. It is primarily used in conjuction with Error Control, Routing and Diagnostics on a network.


Application Level Protocols

There are many Application level protocols that sits on top of TCP/IP and also UDP/IP.

These protocols are responsible for communication between your web browser and a web server, your mail reader and a mail server, and many other applications that you use every day.


HTTP

HTTP stands for Hyper text Transfer Protocol, and it's primary use these days are to handle the sending of request to a web server, and also the recieving of data by the client.

(todo: add more info)


SMTP

(todo: add more info)