TCP/IP Networking basics
Topology
A number of hosts connected to a central switch, and connected to other networks through a gateway (router).
Layers (TCP/IP stack)
Link (OSI 2/1)
The link layer handles the actual transmission of data, relying on dedicated hardware (a networking interface) identified by a unique 48 digits MAC address.
Internet (OSI 3)
This layer is used to transport data between nodes in a network.
Transport (OSI 4)
This layer is responsible for communication between processes, and utilizes different ports for different services.
At this layer information get segmented for transmission.
Application (OSI 7/6/5)
This layer features application protocols like http, ftp, smtp.
The application layer is responsible for transmitting user data between applications.
Transport layer protocols
IP
Identifies hosts and defines routing paths.
IPv4 address
An IPv4 address is a 32 bits number.
In an IP addresses, the first N
bits represent the the network the
address belongs to, while the remaining n
bits identify the host.
Network classes
Network addresses are grouped in classes. Each class a network address designed for private use.
- Class A
N = 8: [1-127].x.x.x/8 (255.0.0.0)
private network:
10.x.x.x/8
- Class B
N = 16: [129-191].x.x.x/16 (255.255.0.0)
private network:
172.16.x.x/12
- Class C
N = 24: [192-223].x.x.x/24 (255.255.255.0)
private network:
192.168.x.x/16
- Class D
[224-239].x.x.x
Class D is reserved for multicast.
- Loopback
127.0.0.1/32
- Link local addresses
169.254.x.x/16
It is assigned when dynamic addresses can't be obtained (via DHCP). It is not routable.
ICMP
It's a protocol used to diagnose network issues.
TCP
Encapsulates data into packets and trasmits them to the remoce end of the connection; it can check for errors and resend packets if needed.
TCP packets are reassembled into one logical piece of information to be sent to the application layer.
UDP
Its an unreliable, connection-less protocol: data are sent to the remote end without any prior connection established, and without checking (and thus resending) lost packets.
It's faster than TCP and employed where low latency is a must and data integrity is not a requirement.