NETWORK LEVEL
In telecommunications and information technology in the context of computer networks, the network layer is level 3 of the ISO / OSI stack. This layer receives segments from the above transport layer and forms packets which are passed to the underlying data link layer. The task of the network layer is the logical transmission of packets between two arbitrary hosts, which in general are not directly connected (that is, they do not have a direct connection between them), i.e. essentially it deals with addressing and routing to the right destination through the most appropriate network path.
NETWORK LEVEL FUNCTIONS
- Forwarding, i.e. receiving a packet on one port, storing it and retransmitting it on another. This feature is present in all nodes of the network and may involve the use of different link layer protocols;
- Fragmentation and reassembly: if a received packet is too large for the network on which it is to be transmitted, the network layer divides it into fragments and, in a complementary way, deals with reassembling the fragments received at the time of delivery;
- Routing, i.e. determining the ideal path for data transmission across the network starting from the recipient’s IP address. In most cases, this function is performed dynamically through special algorithms, which use information from routing protocols on network conditions, routing tables, service priority and other secondary elements.
IP PROTOCOL
In the TCP/IP model, the third layer is called the internet layer or internetworking layer, as it interconnects heterogeneous networks, which can be based on link layer protocols (for example ethernet, PPP) or on network protocols (for example Frame Relay , Asynchronous Transfer Mode), to create a single network in a transparent way to users. The strength of IP lies precisely in this agnosticism with respect to the network level, which allows to use or reuse technologies already available, and to adapt naturally to new technologies. Observing an IP network built with heterogeneous technologies, it can be seen that some nodes of the network run IP (and are called routers); other nodes route IP packets using other networking technologies (which are under IP in the protocol stack). These nodes are normally called switches or switches, even if the term par excellence specifically indicates the ethernet switch. IP determines the best path (called Routing or routing) for forwarding packets, by consulting the routing tables. These tables can be of the static type (created manually by the network operators) or dynamic (composed with the use of routing protocols such as OSPF, RIP or BGP which serve to populate these tables by exchanging information between the various devices on known routes). The network layer takes the segments from the transport layer on the sending host. In this layer, the “messages” sent between hosts are called “IP datagrams”. On the sender side, it encapsulates the segments in datagrams while on the receiver side, it delivers the segments to the transport layer. The router examines the header fields in all IP datagrams that pass through it. The IP protocol only provides unreliable packet delivery:
- Delivery is connectionless (Each package is treated independently from all others, regardless of the history)
- Delivery is not guaranteed: packages can be lost, duplicated, or arrive out of order.
WHY
Layer 2 and 3 devices (switches and routers) are the cornerstones of the network: they must process thousands of packets per second with hardware as reduced to the bone as possible and have reduced response times in order not to slow down the entire network by introducing latencies . Connection control and guaranteed delivery are more advanced features, which we leave to the higher level protocols (4 and 5) run by more performing machines at the “edges” of the network (such as the end user’s PC) which will only have to deal with own traffic, and don’t even sort out everyone else’s traffic!
THE ARP PROTOCOL
Hosts directly connected to the same network are identified with the MAC Address. How can A send a message to the IP address 192.168.0.4? it should know the MAC Address associated with that IP!
HOW DOES IT WORK
- A sends a broadcast message to all MAC addresses on its network, asking who has the IP in question.
- The message will be ignored by everyone except C who replies “it’s me”
- A stores the association between IP and hardware address to reach it.
ARP TABLE
The list of all MAC Address: IP Address associations is saved in the “ARP Cache“, also known as the “ARP Table” of the hosts. We can consult the ARP Table on our Windows or Linux host with the arp command:
INTERNET PROTOCOL IPV4
The following figure shows an IP datagram, the IP portion of the TCP/IP frame that acts as a data envelope and contains the information necessary for routers to transfer data between two or more subnets.
EXPLANATION FIELD DATAGRAM IP
- Version number (4 bits) Indicates the IP protocol version needed to know which fields to expect. Typically “4” (for IPv4), and sometimes “6” (for IPv6)
- Header length (4 bits) Number of 32-bit words in the header typically “5” (20-byte IPv4 header). It can be higher if “IP options” are used
- Type-of-Service (8 bits) It allows to differentiate the packets according to the low delay services for audio, high bandwidth for FTP etc.
- Total length (16 bits) Number of bytes in the packet the Max value is 63.535 bytes (216 -1) although the Datalink level imposes stricter limits
- Fragmentation information (32 bits) Packet identifier, flags, and fragment offset. It supports splitting an IP packet into fragments in case the link does not manage the size of the IP packet
- Time-To-Live (8 bits) Used to identify packets lost in forwarding loops and eventually discard them from the network. A forwarding loop can cause packets to spin forever, this creates confusion if the packet arrives too late. TTL is decremented by each router on the Source-to-Destination path. The Packet is discarded when TTL becomes 0 and a “time exceeded” (ICMP) message is sent to the source.
- Protocol (8 bits) Identifies the protocol being transported 6 for Transmission Control Protocol (TCP) 17 for User Datagram Protocol (UDP) Important for receiving end demultiplexing as it indicates what kind of header to expect.
Checksum (16 bits) Sum all 16-bit words in the IP header (only the Header not the data) if a bit of the header is altered in transit, the checksum will be different from the one in reception. The receiving host discards the corrupt packets. The transmitting host will have to retransmit the packet, if requested
Two IP addresses
- Source IP address (32 bits)
- Destination IP address (32 bits)
- Destination address
- Unique identifier for the receiving host, it allows each node to make routing decisions.
- Source address
- Unique identifier for the transmitting host, the receiver can decide whether to accept the packet, it also enables the receiver to respond to the transmitter.
- Destination address
EXAMPLE OF FRAGMENTATION
In packet data transmission networks, such as in IPv4, a quantity is introduced, called Maximum Transmission Unit (MTU), which indicates the maximum amount of data that can be transmitted over the network, with a single packet. For example, on an Ethernet network, the standard MTU size is 1500 bytes, while on a Token ring network it is 4096 bytes. Fragmentation occurs when a packet larger than the MTU is placed on the network and must be transmitted. For example, suppose that an IP packet of 2396 bytes is to be transmitted over an Ethernet network (with MTU = 1500). Then this package will have to be fragmented into two packages.
First package
It will be 1500 bytes long in total, equal to the MTU of the Ethernet network. Of these, 20 will be used for the IP header, 24 bytes will be for the TCP header, and 1456 will be for data. Furthermore, this packet will have, in the IP header, the DF bit set to 0 to indicate “possible fragmentation”, the MF flag set to 1 to indicate “further fragments present”, and the “Fragmentation Offset” field. set to 0. This last field is measured in terms of 8-byte (64-bit) units.
Second package
it will be 940 bytes long in all. As before, 20 are IP header, 24 are TCP header, and 896 are data. In the IP header there will therefore be the DF bit always equal to 0, but the MF bit set to 0 to indicate “last fragment”. The “Fragmentation Offset” will now have value 182 (ie 1456/8). Note that 2396 is obtained by adding the dimensions of the headers in addition to those of the data: therefore 2396 = 24 + 20 + 1456 + 896. Fragmentation is particularly known on the Internet, as routers placed along the path often use different physical means to the connection, and therefore different protocols at the datalink level, each with its own MTU. In the case of protocols that support a minimum limit of data to be transmitted, the opposite will be done, ie by assembling packets or zero padding to reach the required minimum limit of bits. In any case, upon reception, the continuous flow of data will be restored by means of an ordered reassembly of all the packets relating to the same transmission.
IP ADDRESSES (IPV4)
It is represented by a unique 32-bit number that identifies an interface on a host, router etc. It can be represented in dotted-quad notation.
ADDRESSING SCHEME
An IPv4 address is expressed in 32-bit strings in dotted decimal notation. Each IP address can be associated with a name (DNS).
HOW AN IP ADDRESS WORKS: NET ID and HOST ID
The IP address contains two pieces of information:
- the network name (Net ID)
- the name of the single host (Host ID):
In this image, there are two networks: the 192.168.0.0 network and the 192.168.1.0 network. All computers on each of these two networks can communicate with each other, but no computer on the 192.168.0.0 network can communicate with any computer on the 192.168.1.0. network (We will see later how and why)
IP ADDRESS CLASSES
We can arbitrarily decide how to share NetID and HostID!
For example, we can have addresses where:
- 24 bits indicate the network name, the remaining 8 the host
- 16 bits for the network, 16 for the host
- 8 bits for the network, 24 for the host
Let’s fix the address for a moment and move the netmask to understand how it changes:
The class A addresses have netmask 8, those of class B have 16 and those of class C 24. The following table summarizes the range of addresses reserved for each class.
This will help you immediately determine the class to which each IP address belongs. ES: the address 88.50.95.140 is class A because it falls in the range 1.0.0.0 … 126.255.255.255.
EXPLICIT NOTATION
The bit mask can be explicitly represented as a quartet of numbers that can be represented with 8 bits (i.e. from 0 to 255) as follows:
SUBNET EXAMPLES
The following is a classic class C network (24-bit network prefix):
⇒ we can have up to 256 addresses, from 0 to 255:
⇒ The first and last (0 and 255) are reserved and cannot be assigned to any host:
⇒ 0 indicates the network without referring to any host
⇒ 255 is the broadcast address
⇒ In this network we can have a maximum of 254 hosts (256-2).
To contain more than 254 hosts in a single network, we can use netmask 16:
⇒ The first and last addresses (0.0 and 255.255) are special and cannot be used
⇒ the assignable IP addresses range from 0.1 to 255.254
IP ASSIGNMENT
The IP address can be assigned:
- Dynamically, from a DHCP server on the same network
- Statically, through configuration files on the host
SPECIAL ADDRESSES
Some addresses are “special” in the sense that they do not refer to a host on the network but have a different function:
ADDRESS |
VALUE |
127.0.0.1 |
localhost |
0.0.0.0 |
invalid address: “all IPs of this host” (srv scope) |
198.168.1.255 |
Network broadcast address 192.168.1.0 |
255.255.255.255 |
Broadcast address of the network where we are |
OTHER CLASSES OF ADDRESSES
CLASS |
RANGE |
INFO |
Class D |
from 224.0.0.0 to 239.255.255.255 |
Multicast |
Class E |
from 240.0.0.0 to 255.255.255.254 |
Future experiments |
EXAMPLE OF A CLASS ADDRESS
EXAMPLE OF B CLASS ADDRESS
EXAMPLE OF C CLASS ADDRESS
CLASSLESS AND CIDR ADDRESSES
The division into classes is very strict because we move from networks with 250 hosts (Class C) to networks with 65534 hosts (Class B) to networks with millions of hosts (Class A). ⇒ We can define networks with greater granularity, further breaking the subnet mask!
By specifying a netmask /23 we are stripping a bit from the network prefix, and leaving an extra bit for the hosts, which are now 29 – 2 = 510. Now the addresses for hosts range from 192.168.0.1 up to 192.168.1.254 This practice it is called supernetting
SUBNETTING AND SUPERNETTING
supernetting: Increase the size of a network by reducing the subnet mask
subnetting: Splitting a network into many small subnets by increasing the subnet mask
The notation we used is Classless Inter-Domain Routing (CIDR) notation.
NON-ROUTABLE ADDRESSES AND SEMI-PRIVATE NETWORKS
Given the ever-increasing number of devices connected to the network, IANA has defined private addressing spaces, or “ranges” of addresses for local use. These are also called non-routable addresses because they are automatically discarded by all routers on the Internet (AS and ISP).
CLASS |
RANGE |
MASK |
INFO |
Class A |
[10.0.0.0 – 10.255.255.255] |
10.0.0.0/8 |
1 network |
Class B |
[172.16.0.0 – 172.31.255.255] |
172.16.0.0/12 |
16 network |
Class C |
[192.168.0.0 – 192.168.255.255] |
192.168.0.0/16 |
256 network |
Every home/business/ office… can use these same addresses locally, and go out on the internet with a single IP address: that of your modem router:
This system:
- It reduces the use of public IP addresses
- Doesn’t directly expose hosts to the internet (security benefit!)
ES: Host A (B, C, …) will not be reachable from the external network!
⇒ This type of network is called “semi-private“.
But in a sense, A must be reachable, otherwise how do we navigate?
NATTING
ES: From computer A I want to visit the site pippo.com
- A sends an IP datagram to my router with the destination address of pippo.com
- my router, by forwarding the datagram to the external network, modifies it by replacing the sender’s (local) IP address with its own (public).
- pippo.com will send the response to the public IP address of (my) router. (according to the IP datagram, it is from that address that the request was received).
- My router sees a datagram coming for him!
- My router remembers that the request was originated by A, and modifies the datagram by replacing the recipient’s IP with that of A, and forwards the datagram to A.
What has just happened is called NAT (Network Address Translation) or my router translated A’s IP into a public IP (routable) to circulate on the internet, and then did the reverse process for the reply message.
This practice is called source natting. This is how you surf the Internet from your home!
ROUTER
A router serves to interconnect two (or more) separate networks. It has at least two network interfaces: one facing the first network and one facing a second network. Each router must choose the path in the network through which to deliver the packets.
Each router behaves like this:
- If it knows where the destination address is, it forwards the packet in that direction
- Otherwise, it forwards the packet to its own default gateway
This process is repeated for each router until it reaches the destination host. Below is an example of a Routing table for a common network.
Routing Table: Stores which nodes lead to which network segment.
HOW THE INTERNET WORKS
Backbone: huge networks spanning intercontinental distances to connect states and continents. Organizationally, the Internet is a conglomeration of over 50,000 Autonomous Systems (which we will see shortly), from the smallest on a national scale to the largest on an intercontinental scale.
What are Autonomous Systems?
They are theoretically independent bodies or consortia that:
- They manage “regions” of addresses and sets of networks
- internally they use the same routing protocol
- From the outside they are seen as a single entity.
The AS connect to each other via:
- Peering Point (PP)
- The expenses can be divided for the benefit of both
- Or an AS pays another AS to pass traffic
- Internet Exchange Point (IXP)
- Usually independent non-profit consortia
- Sometimes supported by public funding
HIERARCHICAL ROUTING
A routing protocol (in Italian routing protocol), in telecommunications and information technology, is a network protocol related to the network layer that allows routers to exchange information with each other in order to build routing tables thus allowing the correct routing of packets to the right destination. The use of routing protocols for the automatic and dynamic construction of routing tables becomes necessary when the number of interconnected subnets is high (as in the case of the Internet) as a substitute for the usual static creation by the network administrator in local networks . In the Internet, given the large number of interconnected networks, from the point of view of routing it is convenient to understand the network as a set of autonomous systems (AS) as already seen, each of which deals with autonomously and uniformly managing the internal routing of its own. you will interact with the same routing protocol and interconnect only with the other directly connected ASs. The protocols used are different depending on whether they are routers within the same AS (interior gateway protocol, IGP), or routers that connect multiple ASs (EGP), Exterior Gateway Protocol. As regards the first category, protocols can be divided into two main classes: distance vector and link state. The distance vector ones receive and send information about the links only to the neighboring routers while the link states send it to all the routers of their own autonomous system.
GLOBAL AND LOCAL ROUTING
There are two classes of routing algorithms:
- Global routing algorithms
- All nodes know the status of the entire networ
- ES: Link state protocol
- Local routing algorithms
- Each node communicates its status to the neighbors
- ES: Distance vector protocol
Both types can be used for both internal and external routing to AS.
- For internal use, link state algorithms are often preferred
- Distance vector algorithms are preferred for external use
ICMP
Internet Control Message Protocol
Protocol for basic network diagnostics such as checking the reachability of a host for the detection of malfunctions.
It includes a series of control codes such as:
0 Destination network unreachable
1 Destination host unreachable
2 Destination protocol unreachable
3 Destination port unreachable
…
It is mainly used for
- flow control of datagrams
- determine excessively long cycles or paths
- measure the latency between a sender and a recipient
And it is the protocol used by famous tools such as ping and traceroute.
ping to test the reachability and latency of a recipient host, sending echo request and echo reply messages of the ICMP protocol. As usual, there is encapsulation. An ICMP message, like any other data transported at layer 3, is encapsulated in an IP datagram, which in turn is encapsulated in an ethernet frame for transport:
AI DEEPENING
Layer 3 of the OSI (Open Systems Interconnection) model is the Network Layer. This layer is responsible for managing the routing of data packets through a complex and interconnected network. Here is a detailed description of its main functions and components:
1. Main function: Routing
The network layer is primarily responsible for determining the optimal path to send data from a source device to a destination device through a network of interconnections, such as routers and switches. These devices are located multiple hops away, and the network layer dictates how packets should move from one node to another.
2. Packets and datagrams
The network layer organizes data into packets, called datagrams in an IP-based network environment. These packets include a header that contains crucial information such as the source and destination IP address, as well as various control parameters.
3. Addressing
Another job of the network layer is to assign and manage logical addresses, such as the IP address. This logical addressing differs from physical addressing (for example, layer 2 MAC addresses), because it allows communication between devices that are not directly connected on the same physical network.
4. Network Layer Protocols
The main protocol used at the network layer on the Internet is the Internet Protocol (IP), which comes in its IPv4 and IPv6 versions. IP is responsible for:
•Dividing data into packets.
•Adding routing information (such as IP addresses).
•Sending packets along different paths to their destination.
There are also other protocols that operate at the network layer, including:
•ICMP (Internet Control Message Protocol): Used to report communication errors and for diagnostic functions, such as ping.
•ARP (Address Resolution Protocol): Used to resolve IP addresses to MAC addresses within a local network.
•RIP, OSPF, EIGRP, BGP: These are routing protocols that help determine the best paths for packets through complex networks.
5. Fragmentation
If a packet is too large to pass through a network with a limited Maximum Transmission Unit (MTU), the network layer takes care of fragmenting the packet into smaller pieces. Each fragment will be routed separately, but reassembled at the destination.
6. Quality of Service (QoS)
In some implementations, the network layer also supports Quality of Service (QoS) management. QoS allows packets to be prioritized, ensuring that certain types of data (for example, VoIP calls or real-time video) are prioritized over other, less critical data traffic.
7. Security
Although security is not a primary function of the network layer, some protocols or technologies such as IPsec operate at this layer to ensure that packets are encrypted and authenticated, protecting the communication from attacks.
8. Error Handling and Checks
The network layer is responsible for handling errors that may occur during packet routing. If a packet cannot be delivered, an error message may be sent back to the sender (for example, via ICMP).
9. Types of Routing
The network layer uses several methods to determine the path that packets should take:
•Static routing: routes are manually configured and remain fixed.
•Dynamic routing: routers communicate with each other to exchange information about the networks and dynamically decide the best path.
10. Interaction with other layers
The network layer interacts with the Data Link Layer (layer 2) to send and receive packets between devices on the same physical network, and with the Transport Layer (layer 4), which manages end-to-end transmission between applications, to transport data from one host to another.
Summary of Network Layer Responsibilities:
•Addressing and routing packets.
•Managing network protocols (IP, ICMP, ARP, etc.).
•Fragmenting and reassembling packets.
•Error reporting using protocols such as ICMP.
•Dynamic or static routing of packets across complex networks.
The Network Layer is essential for ensuring that data can travel correctly between devices in local area networks (LAN) and wide area networks (WAN), and is the backbone of the Internet architecture.
IP PROTOCOL
The Internet Protocol (IP) is one of the main protocols used in the network layer (Layer 3) of the OSI model and is the basis of communication on the Internet. IP is responsible for routing data packets from one device to another on an IP-based network, ensuring that data can travel across different networks until it reaches its final destination. There are two main versions of IP in use today: IPv4 and IPv6.
1. Main functions of the IP protocol
The main functions of the IP protocol include:
•Addressing: Assigns unique addresses to devices on the network to identify them and allow communication between them.
•Routing: Determines the path that packets must take across interconnected networks to reach their destination.
•Fragmentation and reassembly: If a packet is too large to pass through a network with a maximum packet size (MTU) limit, IP fragments it into multiple smaller packets. At the destination, the fragmented packets are reassembled into the original message.
•Handling errors and control messages: Uses associated protocols such as Internet Control Message Protocol (ICMP) to report transmission errors or other anomalies.
2. IP packet header format
Each IP packet contains a header with information that is essential for routing and handling the data. The following is a description of the main header entries for IPv4 and IPv6.
IPv4 Header
The IPv4 header consists of several fields:
•Version (4 bits): Specifies the version of the IP protocol, in the case of IPv4, the value is 4.
•Header Length (IHL) (4 bits): Specifies the length of the IP header in 32-bit words (usually 5 words, or 20 bytes).
•Type of Service (ToS) (8 bits): Defines the priority of the packet and how it should be treated by routers in terms of latency, throughput, or reliability (today used for QoS).
•Total Length (16 bits): Indicates the total size of the packet, including the header and data, with a maximum length of 65,535 bytes.
•Identifier, Flag, Fragmentation Offset (32 bits total): These are used to fragment packets if they need to traverse networks with a smaller MTU than the packet size.
•Time to Live (TTL) (8 bits): Contains the maximum number of routers that a packet can traverse. It is decremented for each pass through a router and, if it reaches zero, the packet is discarded.
•Protocol (8 bits): Indicates the upper (transport) layer protocol that is used in the data field of the IP packet (for example, TCP = 6, UDP = 17).
•Header Checksum (16 bits): This is a checksum value that allows you to verify the integrity of the IP header.
•Source IP Address (32 bits): The IP address of the sender of the packet.
•Destination IP Address (32 bits): The IP address of the recipient of the packet.
•Options: This field is optional and can be used for special purposes, such as route tracing or security.
IPv6 Header
IPv6 was designed to overcome some limitations of IPv4, including address space. The IPv6 header is simpler than IPv4, with fewer fields and a fixed length.
•Version (4 bits): In IPv6, the value is 6.
•Traffic Class (8 bits): Equivalent to the ToS field in IPv4, it allows packets to be classified for priority or special treatment.
•Flow Label (20 bits): Allows you to identify packets that belong to the same data flow (for real-time applications such as VoIP).
•Payload Length (16 bits): Specifies the size of the payload, i.e. the data carried by the packet, excluding the header.
•Next Header (8 bits): Specifies the upper layer protocol, similar to the Protocol field in IPv4.
•Hop Limit (8 bits): Works like the TTL field in IPv4, decreasing by 1 for each hop through a router.
•Source IP Address (128 bits): Address of the sender.
•Destination IP Address (128 bits): Address of the recipient.
3. IP Addressing
One of the key roles of IP is to assign unique addresses to devices to identify them on the network.
IPv4 Addressing
IPv4 addresses are represented in 32-bit format, divided into four octets (or bytes), each represented in decimal (for example, 192.168.1.1). IPv4 addresses are limited to about 4.3 billion combinations, but many of these are reserved for special uses (e.g. private networks and multicast).
IPv6 Addressing
To overcome the scarcity of IPv4 addresses, IPv6 uses a 128-bit address space, allowing for a much larger number of addresses (about 340 undecillion). IPv6 addresses are represented by eight blocks of four hexadecimal digits (for example, 2001:0db8:85a3:0000:0000:8a2e:0370:7334).
4. Fragmentation and Reassembly
If an IP packet is too large for an intermediate network (for example, a network with a smaller MTU), it is broken into multiple fragments. Each fragment has a header that allows the recipient to reassemble the fragments in the correct order. In IPv6, only the sender can fragment, while IPv4 also allows fragmentation along the way.
5. Routing
IP uses routing algorithms to determine the path a packet must take to reach its final destination. Routers play a crucial role in routing, deciding the best possible path based on routing tables and algorithms such as RIP, OSPF or BGP.
6. Protocols related to IP
In addition to IP itself, there are protocols that support and complement it:
•ICMP (Internet Control Message Protocol): Used to report errors and diagnose network problems (for example, via the “ping” command).
•ARP (Address Resolution Protocol): Resolves IP addresses to MAC addresses on a local network.
•DHCP (Dynamic Host Configuration Protocol): Dynamically assigns IP addresses to devices that connect to a network.
7. Security in IP
IPsec is an extension of IP that provides authentication and encryption of IP packets, ensuring security in communications between devices.
8. Differences between IPv4 and IPv6
The main differences between IPv4 and IPv6 include:
•Address space: IPv4 uses 32-bit addresses, while IPv6 uses 128-bit addresses.
•Configuration: IPv6 supports automatic address autoconfiguration, while IPv4 often requires DHCP.
•Performance: The IPv6 header is simpler and more optimized than the IPv4 header.
•Security: IPv6 integrates IPsec as a standard feature, while IPv4 does not.
In summary, the IP protocol is essential for routing and managing data communications on the Internet, with IPv6 representing the evolution needed to address the growing demands for global connectivity.
NATTING
NAT (Network Address Translation) is a networking technology used to change IP addresses in packets as they pass through a router or firewall. The main function of NAT is to allow multiple devices within a private network to share a single public IP address when accessing the Internet, thus solving the problem of IPv4 address scarcity and improving network security.
1. Purpose and Functions of NAT
NAT is used for various purposes:
•Sharing a single public IP address: In a private network with many devices, NAT allows all of them to use a single public IP address for external communication. For example, in an office or home, all devices connected to the router share the same public IP assigned by the Internet Service Provider (ISP).
•Increasing Security: NAT acts as a form of firewall, hiding the internal IP addresses of the network, making it more difficult for an outside user to directly access private devices.
•IPv4 Address Preservation: As IPv4 addresses become exhausted, NAT reduces the need for a unique public address for each device, making private addresses (such as those defined in RFC 1918: 10.0. 0.0/8, 172.16. 0.0/12, 192.168. 0.0/16) possible.
2. How NAT Works
NAT works by changing IP addresses and/or TCP/UDP ports in packets that pass between a private network and a public network. During communication:
•When a device within the private network sends a packet to the Internet, the NAT router changes the private IP address of the sender to the public IP address of the router.
•When a response comes back, NAT maps the return packet to the correct private IP address within the network, based on a table that stores the association between the public address and the private address.
3. Types of NAT
There are several types of NAT, each with specific characteristics:
1. Static NAT
Static NAT maps a single private IP address to a single public IP address in a fixed way. It is used when you want a specific device on the internal network (such as a server) to always be reachable from the Internet with the same public address. It is less common, but useful when you need to ensure continuous external access to a particular device.
2. Dynamic NAT
In Dynamic NAT, private IP addresses are dynamically mapped to a pool of public IP addresses. When an internal device requests access to the Internet, the router temporarily assigns an available public IP address from the pool. When the session ends, the public address can be reassigned to another device. This method is less used than Static NAT or PAT.
3. PAT (Port Address Translation) or NAT Overload
PAT, also called NAT Overload, is the most common form of NAT. It allows multiple internal devices to share a single public IP address using separate TCP/UDP port numbers for each session. When a device sends data to the Internet, the NAT router changes both the source IP address and port number of the private device. When the response comes back, the router uses the port number to determine which internal device to send the data to. PAT allows hundreds or thousands of devices to share a single public IP address.
4. How NAT and Ports Work
Port Address Translation (PAT) is especially important because it uses TCP and UDP ports to keep track of connections. Ports are numbers that identify specific communication sessions on a network. When a private device sends a packet:
•The NAT router assigns a random port to the connection and stores it in a NAT translation table along with the device’s original internal IP address and port.
•When a response packet arrives from the outside, the NAT router consults its table to determine which internal device to send the data to, based on the association between the public address and the port.
5. Advantages of NAT
•Reduced use of public IPv4 addresses: Since a single public IP can be shared by multiple private devices, NAT helps preserve limited IPv4 addresses.
•Improved security: NAT hides private IP addresses, making it more difficult for outside attackers to identify and attack specific devices within a network.
•Flexibility in using private IP addresses: Local networks can freely use private addresses without conflicting with public addresses.
6. Disadvantages of NAT
Despite its advantages, NAT does have some limitations:
•Compatibility issues with some applications: Some applications or protocols that use specific IP address information, such as VoIP or online gaming, may encounter problems due to NAT changing addresses.
•Router overload: Handling IP address translations requires computing resources, and in very large networks this can cause additional load on routers.
•Complications in configuring externally accessible services: If you want a device inside your private network to be accessible from the outside (for example, a web server), you need to configure port forwarding, mapping specific ports from the outside to an internal device.
7. Port Forwarding
Port forwarding is a technique used in conjunction with NAT to allow external devices to access services on devices inside a private network. For example, to allow access to an internal web server from the public network, you need to configure your router to forward requests received on port 80 (HTTP) or 443 (HTTPS) to the internal IP address of the server.
8. NAT and IPv6
With the introduction of IPv6, which has a much larger address space than IPv4, the need for NAT should decrease. IPv6 provides public addresses to every device, reducing the need for address translations. However, NAT may still be used in specific scenarios for security or network management purposes.
9. Summary
NAT plays a vital role in IP address management and private network security. Its ability to allow multiple devices to share a single public IP address makes it essential in an era of IPv4 address scarcity. However, it also has some limitations, especially in terms of application-specific compatibility and network configuration management. With the transition to IPv6, NAT use is expected to decline, although it will not disappear entirely.
HOW THE INTERNET WORKS
The Internet is a global network that connects billions of devices around the world, allowing data to be transmitted and exchanged between them. To understand how the Internet works, it is helpful to break it down into its basic elements and explain how each of them contributes to its operation. Here is a detailed description of how the Internet works, from the basics of its physical infrastructure to the communication protocols used to transmit data.
1. Physical Infrastructure
The Internet is based on a complex physical infrastructure that includes:
•Cables and fiber optics: Most Internet traffic travels through networks of cables, often fiber optics, that connect different countries, cities, and continents. These underground and undersea cables allow the rapid transmission of data in the form of light signals.
•Routers and switches: These are devices that direct data traffic between networks. Routers determine the most efficient path for data packets to travel from one point to another. Switches are responsible for sorting packets within a local network.
•Data centers and servers: These are the physical locations where websites, applications, email, and other Internet content are hosted. Servers are specialized computers that provide data and resources to users.
•Internet Exchange Points (IXPs): These are nodes where different Internet Service Providers (ISPs) connect to each other to exchange data traffic efficiently. IXPs are essential for reducing latency and managing interdomain traffic.
2. IP Addressing
Every device connected to the Internet, from computers to mobile phones, must have a unique IP (Internet Protocol) address to identify itself on the network. IP addresses can be:
•IPv4: Older format of IP addresses, based on 32 bits, which offers approximately 4.3 billion possible combinations.
•IPv6: Newer version, introduced to solve the problem of IPv4 address scarcity, with addresses based on 128 bits, offering a much larger address space.
The IP address works like the address of a house, which allows data packets to reach their correct destination.
3. Communications Protocol: TCP/IP
TCP/IP (Transmission Control Protocol/Internet Protocol) is the core protocol on which the Internet is based. It defines how data is broken into packets, transmitted, and reassembled upon arrival. TCP/IP operates on two main levels:
•IP (Internet Protocol): Addresses and routes data packets between sender and recipient.
•TCP (Transmission Control Protocol): Ensures that packets are delivered reliably and in the correct order. When a packet is lost or damaged, TCP requests that it be retransmitted.
4. Dividing Data into Packets
When you send a message or access a web page, the data is divided into packets. Each packet contains a portion of the original data and control information, such as the source IP address, destination IP address, and sequence number. These packets are sent independently of each other across the network and can take different paths to reach their destination. Once they arrive, they are reassembled to reconstruct the original message.
5. Routing and routing
When a packet is sent from one computer to another, it travels through multiple networks and devices. Routing is the process by which packets are routed from the sender to the recipient through various routers, devices that sit at the edges of networks. Each router has a routing table that contains information about the best routes to specific IP addresses.
Packets can travel through local area networks (LANs), wide area networks (WANs), and the global Internet, which is a network of networks, until they reach their final destination. If a packet cannot find a route, the router sends an error message to the sender.
6. Name Resolution: DNS (Domain Name System)
Internet users do not use IP addresses directly, but rely on domain names (such as www.google.com) to access websites or other services. DNS (Domain Name System) is a system that translates these domain names into IP addresses. DNS works in several stages:
•When you enter a domain name into a browser, your computer sends a request to a DNS server.
•The DNS server responds with the IP address corresponding to the requested domain name.
•The browser uses the IP address to send the request to the server hosting the website.
7. Application Protocols
The Internet is not limited to the transfer of data packets, but uses a variety of application protocols that define how certain types of data should be handled. Some of the most important protocols include:
•HTTP/HTTPS (Hypertext Transfer Protocol / Secure): The protocol used for transmitting web pages.
•SMTP (Simple Mail Transfer Protocol): Used to send emails.
•FTP (File Transfer Protocol): Used to transfer files.
•VoIP (Voice over IP): Used to transmit voice over the Internet, such as in Skype or Zoom calls.
8. Connection Services: ISP (Internet Service Provider)
To connect to the Internet, users must go through an ISP (Internet Service Provider). ISPs provide access to the global network through various means, including:
•DSL or fiber optic: Wired connections, usually high-speed.
•Wi-Fi: Wireless connections, often provided by local routers.
•Mobile network: Connectivity through cellular networks (3G, 4G, 5G).
ISPs in turn connect to backbone networks, which are the main communication routes that carry Internet traffic over long distances.
9. Internet Security
Security is a fundamental component of the Internet. It is ensured through various mechanisms:
•Encryption: Encryption, such as that used in HTTPS or SSL/TLS protocols, protects transmitted data, making it unreadable to anyone who does not have the decryption key.
•Firewall: Firewalls control traffic entering and leaving a network, blocking unauthorized data.
•VPN (Virtual Private Network): A VPN creates a secure tunnel between the user and a remote server, encrypting traffic and protecting the user’s identity.
10. Cloud computing and the Internet
One of the main recent developments is cloud computing, which allows the use of services and resources (such as storage, processing and applications) provided on remote servers accessible via the Internet. Data and services no longer reside locally on user devices, but on distributed infrastructures accessible anywhere via the network.
11. How the Web (World Wide Web) Works
The World Wide Web (WWW) is a system of documents and resources (web pages) linked together by hyperlinks, accessible through web browsers. The web mainly uses the HTTP/HTTPS protocol to transfer web pages from servers to user browsers. Browsers send HTTP requests to obtain a resource (such as an HTML file or an image), and the server responds by sending the requested content.
Summary
The Internet works thanks to a complex interaction between physical infrastructure, communication protocols and data management systems. The infrastructure allows devices around the world to connect, while protocols such as TCP/IP and DNS ensure that data is transmitted reliably and efficiently. Security, packet routing, name resolution and access via ISPs are all essential components that allow the Internet to function.
Leave A Comment