Skip to content

Processes, sockets, and ports

Module
TCP, UDP, and Ports
Difficulty
Easy
Updated
Tested on
Ubuntu 24.04.5 LTS, netlab 1.0, GNU Bash 5.2.21, tcpdump 4.99.4
On this page

Web has one address. Laptop and phone both want its page, while web also accepts remote logins. An address gets a packet to web, but does not say which waiting program should receive it. You will find which program waits on each port, then see how web tells two clients apart.

Seven questions from laptop to web A horizontal line joins laptop to web through seven numbered circles. Station 6 is the focus: finding the programs at both ends. laptop web 1 2 3 4 5 6 7
Seven questions from laptop to web A horizontal line joins laptop to web through seven numbered circles. Station 6 is the focus: finding the programs at both ends. laptop web 1 2 3 4 5 6 7
Station 6 is the focus for finding the right programs at the two ends, with earlier stations neutral.
  1. Settings: read and interpreted; their automatic source remains open.
  2. Finding a name: still open, for How DNS Finds Services.
  3. Own network or router: answered in Subnetting Foundations.
  4. Delivery on the cable: answered in Ethernet and Local Delivery and Finding a neighbor with ARP.
  5. Crossing and returning: answered in Reaching Another Device.
  6. Finding programs: the question here.
  7. Application words and privacy: still open, for Everyday Application Traffic.

Finish Practice: Reaching Another Device. Use the running lab with modes off. Leave machine shells and run netlab reset from the VM if settings changed. Enter web with netlab shell web. Keep experiments inside this lab.

Run ss -tln. The command lists sockets. Here -t selects TCP, the transport examined next; -l selects listeners; and -n shows port numbers instead of service names.

Read only the listening ports
learner@web:~$ ss -tlnState    Recv-Q   Send-Q     Local Address:Port     Peer Address:Port  Process  
LISTEN   0        128              0.0.0.0:22            0.0.0.0:*              
LISTEN   0        5                      *:8080                *:*              
LISTEN   0        5                      *:443                 *:*              
LISTEN   0        5                      *:80                  *:*              
LISTEN   0        128                 [::]:22               [::]:*              learner@web:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.0), GNU Bash 5.2.21. Web lists its listening sockets without the owning programs.
Steps (3)
  1. Type ss -tln
  2. Press Enter
  3. Output: State Recv-Q Send-Q Local Address:Port Peer Address:Port Process LISTEN 0 128 0.0.0.0:22 0.0.0.0:* LISTEN 0 5 *:8080 *:* LISTEN 0 5 *:443 *:* LISTEN 0 5 *:80 *:* LISTEN 0 128 [::]:22 [::]:*

The state LISTEN says an end is waiting for incoming connections. Listening means waiting for another program to start an exchange. A port is a number naming a program’s end of a conversation on a machine. A socket is an end of a conversation that the operating system keeps for a program.

The local address column ends with the port. A wildcard, *, means any local address supported by that socket. It does not mean every machine on the network. The peer wildcard means this listening socket is not tied to one client.

Read a listening socket

LISTEN   0        5                      *:80                  *:*              
web
server
local
StateLISTEN
Local address*
Port · Transport80

Reading the output

Pick a step to match a marked part of the output to the picture.

Step-by-step reading of a captured output · Output of ss -tln on web, on Ubuntu 24.04.5 LTS, netlab 1.0, tcpdump 4.99.4. The values are the capture's. Read one captured listening line: its state, local address wildcard, and port.
Steps (3)
  1. State. State: LISTEN. Shown on web's local as: State. The socket is waiting for incoming connections.
  2. Local address. Local address: *. Shown on web's local as: Local address. The wildcard accepts any supported local address.
  3. Port. Port: 80. Transport layer. Shown on web's local as: Port. The local port is the number after the colon.
Part Meaning
LISTEN Waiting for connections
* Any supported local address
80 Local port

A server waits on a known port. A client normally gets an unused local port from its operating system.

Predict: two clients use the same destination port. What makes their conversations different?

Open three terminals. On laptop run curl telnet://10.77.20.80:80 and leave it running. On phone run the same command and leave it running too. This opens a connection without asking for a page. Both programs wait, so you have time to read the list. A page request ends too quickly to catch in the list.

In the third terminal, on web, run ss -tn. Removing -l selects active conversations instead of listeners. Then press Ctrl+C on phone and laptop to close their waiting commands.

Hold the first client connection on laptop
learner@laptop:~$ curl telnet://10.77.20.80:80^Clearner@laptop:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.0), GNU Bash 5.2.21. Laptop holds its connection until the server listing has been read.
Steps (4)
  1. Type curl telnet://10.77.20.80:80
  2. Press Enter
  3. Phone has closed its connection after web listed both. Return to laptop and press Ctrl+C.
  4. Press Ctrl + C
Hold the second client connection on phone
learner@phone:~$ curl telnet://10.77.20.80:80^Clearner@phone:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.0), GNU Bash 5.2.21. Phone holds a second connection while the third terminal reads web.
Steps (4)
  1. Type curl telnet://10.77.20.80:80
  2. Press Enter
  3. The third terminal on web listed both connections. Return to phone and press Ctrl+C.
  4. Press Ctrl + C
List both client connections on web
learner@web:~$ ss -tnState Recv-Q Send-Q        Local Address:Port         Peer Address:Port Process 
ESTAB 0      0      [::ffff:10.77.20.80]:80   [::ffff:10.77.10.10]:36994        
ESTAB 0      0      [::ffff:10.77.20.80]:80   [::ffff:10.77.10.11]:46882        learner@web:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.0), GNU Bash 5.2.21. Web lists two established conversations with the same local port.
Steps (3)
  1. Type ss -tn
  2. Press Enter
  3. Output: State Recv-Q Send-Q Local Address:Port Peer Address:Port Process ESTAB 0 0 [::ffff:10.77.20.80]:80 [::ffff:10.77.10.10]:36994 ESTAB 0 0 [::ffff:10.77.20.80]:80 [::ffff:10.77.10.11]:46882

Web’s socket accepts IPv4 and IPv6, so it displays the IPv4 client as [::ffff:10.77.10.10]; IPv6 itself comes later.

Two conversations reach web port 80 Conversation 1: 10.77.10.10:36994 ↔ 10.77.20.80:80. Conversation 2: 10.77.10.11:46882 ↔ 10.77.20.80:80. Separate lines reach web’s port 80. Intermediate devices are omitted. laptop phone web Port 80 Conversation 1: 10.77.10.10:36994 ↔ 10.77.20.80:80 Conversation 2: 10.77.10.11:46882 ↔ 10.77.20.80:80
Two conversations reach web port 80 Conversation 1: 10.77.10.10:36994 ↔ 10.77.20.80:80. Conversation 2: 10.77.10.11:46882 ↔ 10.77.20.80:80. Separate lines reach web’s port 80. Intermediate devices are omitted. laptop phone web Port 80 Conversation 1: 10.77.10.10:36994 ↔ 10.77.20.80:80 Conversation 2: 10.77.10.11:46882 ↔ 10.77.20.80:80
Laptop's 36994 and phone's 46882 both reach web port 80, with intermediate devices omitted; client ports vary, so your number will differ.
Check your answer

Both local ends are 10.77.20.80:80. Laptop’s peer pair is 10.77.10.10:36994; phone’s is 10.77.10.11:46882. Within TCP, the two IP addresses and two ports distinguish a conversation. The client pairs differ, so web can tell these conversations apart.

You used these same two addresses and two ports to group rows in Following an exchange. A destination port alone does not tell web which client sent the bytes.

“A port is a physical socket.” The hardware port in Switches, routers, and access points is a connector. This port is a number in transport communication.

“One port serves only one client.” The two ESTAB lines share web’s port. That state means established: the conversation is open.

Line order and client ports vary. Match the address and port together, not the row number. The list shows what web is waiting for now. It does not prove that a client can reach web.

On web, run ss -tln again. Match each distinct port to the services in the lab cast. Compare your matches with a program check: run sudo ss -tlnp, typing your Ubuntu password when asked. Explain what the added column tells you and what it leaves unanswered.

Solution
Check the programs behind the listeners
learner@web:~$ sudo ss -tlnp[sudo] password for learner: State     Recv-Q    Send-Q       Local Address:Port        Peer Address:Port    Process                                                                         
LISTEN    0         128                0.0.0.0:22               0.0.0.0:*        users:(("sshd",pid=113,fd=4))                                                  
LISTEN    0         5                        *:8080                   *:*        users:(("python3",pid=107,fd=3))                                               
LISTEN    0         5                        *:443                    *:*        users:(("python3",pid=108,fd=3))                                               
LISTEN    0         5                        *:80                     *:*        users:(("python3",pid=106,fd=3))                                               
LISTEN    0         128                   [::]:22                  [::]:*        users:(("sshd",pid=113,fd=3))                                                  learner@web:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.0), GNU Bash 5.2.21. Add the owning program names after matching the ports to the cast.
Steps (6)
  1. Type sudo ss -tlnp
  2. Press Enter
  3. Output: [sudo] password for learner:
  4. Type the password (the terminal shows nothing)
  5. Press Enter
  6. Output: State Recv-Q Send-Q Local Address:Port Peer Address:Port Process LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=113,fd=4)) LISTEN 0 5 *:8080 *:* users:(("python3",pid=107,fd=3)) LISTEN 0 5 *:443 *:* users:(("python3",pid=108,fd=3)) LISTEN 0 5 *:80 *:* users:(("python3",pid=106,fd=3)) LISTEN 0 128 [::]:22 [::]:* users:(("sshd",pid=113,fd=3))

Ports 80 and 8080 supply HTTP, 443 supplies HTTPS, and 22 accepts SSH. The added -p shows which programs own the sockets: python3 for the page services and sshd for SSH. The name tells you which program opened the socket. But python3 alone does not prove which application protocol its code speaks.

  • Read local address and port together.
  • Separate a listener from its established conversations.
  • Use both client and server pairs to distinguish conversations.

Next, Opening and closing TCP connections explains the rows around a request.