TCP/IP
TCP/IP stands for Transmission Control Protocol/Internet Protocol. TCP/IP is the primary protocol of most modern networks to allow computers to share information over a network.
To move data from one side of a network to another, data is broken up and sent in discrete chunks called frames. The NIC (network interface card) on your PC is in charge of creating and processing these frames. Within a frame, you’ll have:
- An Ethernet header at the beginning of the frame
- The Ethernet payload with the data to be transferred
- An Ethernet trailer at the end of the frame.
Within the Ethernet payload, there’s an IP header and an IP payload. The IP header contains information about the source IP (where the data originates from) and the destination IP (what IP should this data be sent to).
The IP Payload is further broken down to what could be a TCP header and a TCP payload. The TCP Header would contain information about the TCP source and destination ports. Within the TCP payload would be your application data (such as HTTP data) that you are attempting to transfer over the network. Instead of a TCP Header and TCP Payload. You could also have a UDP header and UDP Payload. See the TCP vs UDP article for more information about the differences between the two.
IPv4 Sockets
IPv4 socket consists of:
- the Server IP address, protocol, server application port number
- the Client IP address, protocol, client port number
Port Numbers
Port numbers are used for communication. We need to know where to send data so that is where port numbers come in. There are 2 types of port numbers, non-ephemeral ports and emphemeral ports.
Non-ephemeral ports are permanent. These are ports 0 through 1,023. These are port numbers assigned to an application. Most servers (services) use non-ephemeral port numbers, but that may not always be the case.
Ephemeral ports are temporary. These are ports 1,024 to 65,535. These port numbers are determined in real time by the client. The client randomly generates an emphermeral port number so that it can send information to the server and the server will have a way to get information back to the client by identifying the empheral port assigned at the time of the session.
TCP/IP Example
In the picture below we see an example of what communication would look like to an email server (TCP Port 143) and to a VoIP server (UDP: 5004). The IP header contains the source IP (the client’s IP) and the destination IP (the server’s IP) so the data knows where to go. Next we need to know what ports to process the application data. The TCP/UDP header contains the source port (an ephemeral port number that the client randomly generated) and the destination port (usually the known port of that particular service). And of course the actual data is sent along to the server.