What is TCP/IP and how does it work


In a network, devices need to communicate. For this, communication protocols and models for them emerged. Among them, there is the TCP/IP model . The name comes from two of its protocols, TCP and IP .

In a simple way, it can be said that protocol is the “language” that the equipment connected in a network use to communicate. In this way, equipment from different technologies, manufacturers and purposes can understand each other.

Without standardized communication protocols, it would be difficult, for example, for a worldwide network such as the Internet to exist.

To standardize the creation of protocols, the OSI ( Open Systems Interconnection ) model was created in 1971 and formalized in 1983. This model defines a protocol architecture for networks. With it, different manufacturers can produce their equipment in order to communicate, interpret the information contained in the communication and perform the requested task.

The OSI model predicts that a network must have 7 layers:

Application – Specialized application-level functions

Presentation – Data formatting and character and code conversion

Session – Negotiation and establishment of connection with another node

Transport – Means and methods for delivering end-to-end data

Network – Routing packets across one or more networks

Link – Detection and correction of errors introduced by the transmission medium

Physical – Transmission of bits through the transmission medium


TCP/IP is a set of communication protocols. The name comes from two protocols TCP (Transmission Control Protocol) and the IP (Internet Protocol). It aims to standardize all network communications, particularly web communications.

This model was developed in 1969 by the US Department of Defense as a communication resource for the ARPANET, the precursor to the Internet. It had the function of allowing the exchange of a large volume of information between an immense number of computer systems involving companies, universities and government agencies, all with great speed and reliability.

He should have the ability to decide the best route to follow within the network formed by the organizations involved. In 1983, with the formalization of the OSI model, TCP/IP was adapted to the model and defined as a network communication standard. Then, expanding to the external interconnection of these networks and constituting the Internet communication standard.

The TCP/IP model has only 4 layers that encompass the 7 layers of the OSI model. The higher layers receive information and distribute it to the lower layers, attributing to each one of them the role it will play during the communication.

Comparison with OSI model

Compared to the OSI model, you can see how the 4 TCP/IP layers and their functions are related:

Application (Layer 4)

Here you will find all the service protocols that communicate directly with the software to identify the type of request being performed.

Thus, we find HTTP that allows web browsing, DNS that converts the browser’s url into a unique number (IP) used to identify the location on the network of the medium to be connected, SMTP used to send e-mails. mails, SSH that allows a secure remote connection and many others.

After the communication between software and the Application layer, the information is encoded within the protocol standard and passed on to the lower layers.

Transport (Layer 3)

Responsible for communication between the points (hosts) involved. It has the function of maintaining the reliability and integrity of the communication, verifying if the packet reached its destination and if the data contained therein arrived in an integral way.

Here we find TCP, used in the point-to-point connection. Being a more reliable connection protocol, it is used in applications that do not have much tolerance for packet loss.

We also find the UDP protocol (User Datagram Protocol), a protocol with a not so reliable connection. It does not verify the reliability and integrity of the information, however, as it does not have the control characteristics that are relevant to TCP, it allows for faster transmission of information.

Thus, we have TCP as the main protocol for connection between applications and UDP for media traffic (videos and audios), where speed is more important than integrity.


This layer uses logic gates to ensure that the application (software) that initiated the conversation will find the desired application at its destination. These logical ports are random virtual channels, generally defined by the Operating System, which open according to the type of application running, for example, HTTP uses port 80, FTP uses port 21, etc.

This virtual channel ensures that an application that initiates a call through port 80, such as using a browser to open an HTTP page on computer A, finds, at the destination, the web server that will provide the HTTP page requested also by a port 80. This prevents the information from being misdirected to another application, such as an FTP server (port 21).


Some types of hacker attacks, such as DDoS (denial of service), use the overhead of requests on a certain port, causing the service to drop. For example, millions of simultaneous connection requests over port 80 of a web server are capable of causing the service to be disconnected and, consequently, the withdrawal of the pages it hosts for users.

To avoid this, the Transport layer continually tries to analyze and measure how much the network is loaded and performs a “load balance”, reducing the rate at which packets are sent to avoid overloading.


Another important function is the proper delivery of information packets, verifying the sequence of arrival of packets, because, during the traffic, some can get lost. To illustrate, let’s say that information produced in equipment A, destined for equipment B, given its size, was partitioned at the origin into 10 packets and forwarded to point B.

Upon reaching point B, the transport layer, through TCP, verifies the sequence and, if a packet has been lost along the way, it requests the origin to resend it.

Thus, if point B received packets 1, 5, 3 and 2, TCP reorders the sequence, checks for the absence of packet 4, requests the resend of this packet and, when it arrives, puts it in the correct sequence so that the destination interpret the information in its fullness.

Internet or Network (Layer 2)

It can be said that here is the GPS of the TCP/IP packet, because within this layer we find the source and destination addresses of a connection.

During all the packet traffic through the network, it finds several devices that direct it to the best route in order to reach its destination. These devices are called routers and, in an analogy, they can be defined as nodes of a network.

When the router receives the packet, it reads the Internet (or Network) layer, checks the destination address, checks the internal list of routes it has, and directs the packet to the proper path, which can be the longest path with least traffic or the shortest.

Upon reaching the destination, the equipment stores the source address of the received packet, triggers the requested application in the Transport layer, performs the requested action in the Application layer, formulates the response, encapsulates the response in another TCP/IP packet, puts it as destination the stored source address and inserts its address as the source address.

Within this layer we can find the ICMP and IGMP protocols. The first is used to transmit diagnostics over the network that is traveling. The second is used for data multicast management.

Another function of this layer is to carry routing protocols. For example, BGP, OSPF and RIP, which deliver captured information about network traffic to routers as the protocol passes through them. This allows these devices to improve their route lists. Also, target future packets more appropriately.

Link or Physics (Layer 1)

Its function is to identify the physical connection of the network through which the packet travels. For example, Ethernet, Wi-Fi, Dial-up Modem, ATM, FDDI, Token Ring, X.2. In addition, it carries with it the identity of the hardware that originated the packet sending, storing its MAC address.

Responsible for adapting the package to the physical environment through which it is traveling. It allows the packet to travel through different means, through different interconnections and interoperations of highly heterogeneous networks. This is one of the greatest strengths of TCP/IP. Older protocols allowed traffic only on the same physical medium.

It is through this layer that a notebook or smartphone, connected to the internet through Wi-Fi, has a request sent by the radio frequency, can have the signal converted to travel in the optical fiber of the internet equipment provided by the operator and arrives at the destination. .

Another feature of this layer is the translation of names and logical addresses into physical addresses, in addition to managing the traffic and speed rates of the communication channels.

Finally, another function is the partitioning of information into smaller packets, as we mentioned in the example given in the Transport layer.

While the Transport layer is responsible for the correct sequencing of packets of subdivided information, the Data Link layer is responsible for the division and this information.

It also has the following features:

  • Establish and terminate connections;
  • Notify and correct failures;
  • Use analog or digital signals in connections;
  • Use guided (cables) or non-guided (radio, microwave) means;
  • Emission of more than one signal on the same physical medium;
  • Map logical to physical addresses;
  • Converts physical addresses into logical (IP address);
  • Switch packets within a device;
  • Allows TCP/IP to be implemented on different hardware.

The TCP Protocol

TCP is a reliable transport layer protocol that aims to ensure that data is fully transmitted to the correct destination hosts in the sequence in which it was sent.

TCP partitions (segments) the information received from the Application Layer into smaller blocks of information, known as datagrams, and embeds an identification header that allows the destination host to recompose the data. This header contains a set of bits (checksum) that allows validation of the data and the header itself.

This set of bits allows the destination host to recover information in case of transmission errors or in cases where the information cannot be recovered or the TCP/IP packet is lost during transmission. It is TCP’s job to retransmit the packet.

In order for the source host to be assured that the packet arrived without errors, the destination host informs the transmission status by sending an acknowledgment message .

In order to be able to identify to which service a given datagram belongs, TCP uses the concept of ports. A service is associated with each port. After determining the port, all communication with the application is carried out and addressed through it.

TCP features

Data transfer : Full-duplex standard between 2 points, that is, both connected points can transmit and receive simultaneously.

Data transfer with different priorities : Interprets the priority signals and organizes the routing of datagrams accordingly.

Establishment and Release of Connections : Requests and accepts the initiation and termination of transmissions between hosts .

Sequencing : Ordering of received packets.

Segmentation and reassembly : Divides larger information into smaller packets for transmission. Thus, identifying them in order to be properly regrouped upon receipt.

Flow control : Analyzes the transmission conditions (speed, physical medium, traffic, etc.) and adapts the datagrams for this transmission.

Error control: Through the set of bits (checksum) of its header, it verifies if the transmitted data is free of errors. In addition to detection, it is also possible to correct it.

IP Multiplexing : Since the concept of ports is used, it is possible to send data from different types of services (different ports) to the same destination host.

The IP Protocol

The IP protocol defines the mechanics of datagram transmission, having as a characteristic connection orientation. Each IP packet is treated as an independent unit of information, having no relation to any other.

It is responsible for the communication between the hosts of a TCP/IP network, managing the transport of a message from a source host to a destination host. It does this even when your datagram needs to go through multiple subnets.

However, the IP protocol is unreliable as it does not use any flow control or error handling. This is the responsibility of higher layer protocols.

Its most relevant functions are the assignment of an addressing scheme that is independent of the addressing of the network used and independent of the network topology itself.

In addition, it has the ability to route and make routing decisions for the transport of messages between the elements that interconnect the networks.

IP features

Unreliable datagram service;

Hierarchical addressing;

Ease of fragmentation and re-assembly of packages;

Special field indicating which transport protocol to use at the top level;

Identification of the importance of the datagram and the level of reliability required in order to provide priority in the transmission;

Disposal and lifetime control of packets circulating on the network.

The IP Address

It is the unique and unambiguous identification of each of the hosts that make up a network. It is a set of 32 bits, normally written in decimal and spread over 4 octets. It follows the specifications defined by the NIC ( Network Information Center ). The NIC assigns and controls IP addresses around the world. In this way, the security and uniqueness of the addresses is guaranteed.

It is associated with the host, also with a Network mask that defines the identification, limits and number of equipment on the network where this host is connected.

Due to the existence of networks of various sizes, the concept of Class of Address is used. Thus, it is possible to distinguish the following classes:

A : 128 networks with the ability to address 16 million hosts;

B : 16384 networks with the ability to address 64,000 hosts;

C : 2 million networks with the possibility to address 256 hosts;

D : allows a datagram to be distributed across a set of hosts;

E : These are addresses that start with 1111 and are reserved for future use.

By default, the Internet uses class C for addressing its networks and hosts.  So when a new ISP ( Internet Service Provider ) connects to the internet, it receives at least a set of 256 addresses to use on its hosts . Thus, allowing simultaneous access to the Internet by 256 users.

As the Internet grew exponentially, the available IP addresses decreased dramatically and one way to solve the inevitable running out of IP addresses was to create the concept of subnets.

IPv4 and IPv6

Initially, the Internet was not designed for commercial use. Therefore, with the possible exhaustion of addresses, in addition to improvements in technology, IPv6 was created. IPv6 has 128-bit addresses. In this way, allowing for an immensely greater number of addresses.

TCP/IP Qualities

TCP/IP is the standard protocol. After all, it has a series of qualities that allow enormous versatility in communications. In addition, it allows standardization in the development of new technologies in software and hardware. Notably, the following qualities can be listed as main:

Standardization : It is a standard and a routable protocol that is the most complete and accepted, currently available. All modern operating systems support TCP/IP. Also most big networks rely on it for most of their traffic.

Interconnectivity : is a technology for connecting dissimilar systems. Many standard connectivity utilities are available to access and transfer data between these dissimilar systems. These include  FTP  ( File Transfer Protocol ) and  Telnet  ( Terminal Emulation Protocol ).

Routing : Allows and enables older and newer technologies to connect to the Internet. It works with line protocols such as PPP ( Point to Point Protocol ). In this way, allowing remote connection from dial-up or dedicated line. Also as the IPCs mechanisms and interfaces most used by operating systems, such as Windows sockets and NetBIOS.

Robust Protocol : it is scalable and multiplatform, with structure to be used in client/server operating systems, allowing the use of applications of this size between two distant points.

Internet : it is through the TCP/IP protocol suite that we get access to the Internet. Local networks distribute Internet access servers (proxy servers). Local hosts connect to these servers to gain access to the Internet. This access can only be achieved if the computers are configured to use TCP/IP.


In short, TCP/IP specifies how data is exchanged over the Internet. It provides end-to-end communications. It identifies how they are to be packetized, addressed, transmitted, routed, and received at the destination.

TCP/IP requires little central management and is designed to make networks reliable. With it, it is possible to automatically recover from the failure of any device on the network.

Leave a Reply