- [Instructor] Layer 4 of the OSI model, transport,
uses a 16-bit number, known as a port,
to facilitate endpoint communication.
TCP and UDP both open lines of communication using ports.
Applications will open up a port
and wait for an incoming connection.
This is also referred to as listening.
For well-known applications,
these will be well-known port numbers
like port 80 for HTTP and 443 for HTTPS.
Once the client application
connects to the well-known ports,
the server will sometimes shift the client
to a different port to complete the transaction.
Well-known ports are generally less than 1024.
Ephemeral ports are those above 1024 and are usually used
for short-term communications by clients.
Whenever a packet is created and sent,
the header in that packet will specify
both a source and destination port.
Since the port number is 16-bit,
it can be zero to 65,535.
TCP can't use port zero as it's reserved.
With UDP, the source port number is optional
and a value of zero means no port is used.
An internet socket is created using a transport protocol,
a port number, and an IP address.
This process is known as binding.
Per host, only a single binding is allowed
on a port and IP combination.
Otherwise, conflicts can occur.
When troubleshooting server software that won't start,
an admin may run into the port already in use issue.
This generally stems from another instance
of the software already running
or perhaps another application consuming the same port.
It's not only end hosts and servers that use ports.
Firewalls, routers, and switches also examine port numbers.
Firewalls use port numbers to allow connections
through to various services.
They also use these port numbers
to recognize what types of traffic to expect
and can do additional packet scrutiny
to ensure they conform.
Routers and switches can also use port numbers
for quality of service.
They can use these port designations
to identify certain types of traffic
and elevate their priority as they move through the network.
This can, for example, ensure that VoIP traffic
has a higher priority than web surfing.
Ports are integral to the network
and server's functionality.