0% found this document useful (0 votes)
35 views17 pages

Port Number

The document discusses port numbers, including that they range from 0-65535 and are used to identify network services and applications. Port numbers, along with IP addresses, help route communication to the correct process and enable multiple services to run simultaneously on a single computer.

Uploaded by

yorukage29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views17 pages

Port Number

The document discusses port numbers, including that they range from 0-65535 and are used to identify network services and applications. Port numbers, along with IP addresses, help route communication to the correct process and enable multiple services to run simultaneously on a single computer.

Uploaded by

yorukage29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Operating system

PORT NUMBER
Introduction to port number
• a port is an endpoint to a logical connection and the way a client
program specifies a specific server program on a computer in a
network.

• Some ports have numbers that are preassigned to them by the IANA,
and these are known as well-known ports (specified in RFC 1700).

• Port numbers range from 0 to 65536, but only ports numbers 0 to


1024 are reserved for privileged services and designated as well-
known ports.
Cont’d
• A port number is a 16-bit unsigned integer, ranging from 0 to 65535.
Port numbers from 0 to 1023 are reserved for well-known services
like HTTP (port 80), HTTPS (port 443), FTP (port 21), etc.
• Port numbers from 1024 to 49151 are registered ports, typically used
by specific applications.
• Port numbers from 49152 to 65535 are dynamic or private ports,
which can be used by any application on an ad hoc basis.
Cont’d
• When a process or service wants to communicate over a network, it
binds to a specific port number on the system.
• When another process wants to communicate with it, it specifies the
destination port number along with the IP address of the target
system.

• This combination of IP address and port number helps route the


communication to the correct process or service on the destination
system.
Why do we need port number?
Multiplexing: A single computer can run multiple network services or
applications simultaneously.
• Port numbers enable the operating system to differentiate between
these services and direct incoming network traffic to the appropriate
application.
Identifying Services: Port numbers are used to identify specific
network services or protocols running on a system.
For example, web servers typically listen for incoming HTTP requests on
port 80 or port 443 for HTTPS.
Cont’d
Routing: In network communication, data needs to be routed from the
source to the destination.
Port numbers are used along with IP addresses to route data packets to
the correct application or service running on a computer.

Firewall Configuration: Firewalls use port numbers to control access to


and from a network by blocking or allowing traffic based on the port
numbers associated with specific services. This helps enhance network
security by restricting unauthorized access to certain services.
Cont’d
• Inter-process Communication: Port numbers facilitate
communication between different processes or applications on the
same or different computers.
• Processes can communicate with each other over the network by
sending data to specific port numbers where the receiving process is
listening.
How to check a port number running on
window OS
Option 1:
You can use the netstat command in Command Prompt to display a list of all active
network connections and the corresponding port numbers.
1. Open Command Prompt and type:
2. netstat –ano
Option 2:
1. Press Ctrl + Shift + Esc to open Task Manager.
2. Go to the "Details" tab.
2. Right-click on the column header and select "Select columns."
4. Check the "PID (Process Identifier)" and "Local Port" options.
Cont’d
• Option 3:
1. Press Win + R to open the Run dialog.
2. Type resmon and press Enter.
3. In Resource Monitor, go to the "Network" tab, where you can see a
list of active network connections along with their associated processes
and port numbers
How to create a port number?
• To create a port number in a Windows application, you typically don't
"create" a port number as such, but rather use an available port for
communication purposes.
• Choose a Port Number: Ports are numbered from 0 to 65535. Ports
below 1024 are reserved for specific services (like HTTP on port 80,
HTTPS on port 443, etc.), so it's generally recommended to use a port
number above 1024 to avoid conflicts with system services.
Cont’d
• Choose a Port Number: Ports are numbered from 0 to 65535. Ports
below 1024 are reserved for specific services (like HTTP on port 80,
HTTPS on port 443, etc.), so it's generally recommended to use a port
number above 1024 to avoid conflicts with system services.
• The following are steps:
• Open Command Prompt: Press Win + R, type cmd, and press Enter.

• Use the netstat command to list all active connections and listening
ports.
cont’d
• You can filter the output to only show the port you're interested in
using the -a (all connections and listening ports) and -n (display
addresses and port numbers in numerical form) options. For example,
to check if port 12345 is in use:

• netstat -an | find "12345“

Above command will display any connections or listening ports on port


12345. If there's no output, it means the port is not in use
Cont’d
• Alternatively, you can use the tasklist command to check if a specific
process is using a port. For example, if you want to check if port
12345 is being used by a process, you can do:

• tasklist /FI "PID eq <PID>“

• Replace <PID> with the actual PID you obtained from the previous
command.
Cont’d
• Bind to the Port: Once you've chosen an available port, you can bind
your application to it.
• This allows your application to listen for incoming connections on that
port.
How to know is a port number is open or
not?
• To determine if a port number is open or not, you can use various
methods and tools
• 1. telnet command
You can use the telnet command followed by the IP address or
hostname and the port number.
If the port is open, you will see a blank screen or a message indicating
the connection succeeded. If it's closed, you'll receive an error.

• telnet <hostname or IP> <port>


Cont’d
2. Netcat (nc): Netcat is a versatile networking utility that can be used
to check if a port is open.
• nc -zv <hostname or IP> <port>
3. Online Port Scanners
There are many online tools available that allow you to scan a specific
IP address or hostname for open ports.
You can use websites like "[Link]" or "[Link]/
tools/open-ports/".
Cont’d
• Nmap is a powerful network scanning tool that can be used to
discover hosts and services on a computer network. You can use it to
scan for open ports on a specific host or range of hosts.

• nmap -p <port> <hostname or IP>

You might also like