Port (Computer Networking) - Wikipedia
Port (Computer Networking) - Wikipedia
networking)
In comput er net working, a por t or por t number is a number assigned t o uniquely ident ify a
connect ion endpoint and t o direct dat a t o a specific service. At t he soft ware level, wit hin an
operat ing syst em, a port is a logical const ruct t hat ident ifies a specific process or a t ype of
net work service. A port at t he soft ware level is ident ified for each t ransport prot ocol and
address combinat ion by t he port number assigned t o it . The most common t ransport
prot ocols t hat use port numbers are t he Transmission Cont rol Prot ocol (TCP) and t he User
Dat agram Prot ocol (UDP); t hose port numbers are 16-bit unsigned numbers.
A port number is always associat ed wit h a net work address of a host , such as an IP address,
and t he t ype of t ransport prot ocol used for communicat ion. It complet es t he dest inat ion or
originat ion address of a message. Specific port numbers are reserved t o ident ify specific
services so t hat an arriving packet can be easily forwarded t o a running applicat ion. For t his
purpose, port numbers lower t han 1024 ident ify t he hist orically most commonly used
services and are called t he well-known port numbers. Higher-numbered port s are available for
general use by applicat ions and are known as ephemeral port s.
Port s provide a mult iplexing service for mult iple services or mult iple communicat ion sessions
at one net work address. In t he client –server model of applicat ion archit ect ure, mult iple
simult aneous communicat ion sessions may be init iat ed for t he same service.
Port number
For TCP and UDP, a port number is a 16-bit unsigned int eger, t hus ranging from 0 t o 65535. For
TCP, port number 0 is reserved and cannot be used, while for UDP, t he source port is opt ional
and a value of zero means no port. A process associat es it s input or out put channels via an
int ernet socket , which is a t ype of file descript or, associat ed wit h a t ransport prot ocol, a
net work address such as an IP address, and a port number. This is known as binding. A socket
is used by a process t o send and receive dat a via t he net work. The operat ing syst em's
net working soft ware has t he t ask of t ransmit t ing out going dat a from all applicat ion port s
ont o t he net work, and forwarding arriving net work packet s t o processes by mat ching t he
packet 's IP address and port number t o a socket . For TCP, only one process may bind t o a
specific IP address and port combinat ion. Common applicat ion failures, somet imes called port
conflicts , occur when mult iple programs at t empt t o use t he same port number on t he same
IP address wit h t he same prot ocol.
Applicat ions implement ing common services oft en use specifically reserved well-known port
numbers for receiving service request s from client s. This process is known as listening, and
involves t he receipt of a request on t he well-known port pot ent ially est ablishing a one-t o-
one server-client dialog, using t his list ening port . Ot her client s may simult aneously connect t o
t he same list ening port ; t his works because a TCP connect ion is ident ified by a t uple
consist ing of t he local address, t he local port , t he remot e address, and t he remot e port .[1]
The well-known port s are defined by convent ion overseen by t he Int ernet Assigned Numbers
Aut horit y (IANA). In many operat ing syst ems special privileges are required for applicat ions t o
bind t o t hese port s because t hese are oft en deemed crit ical t o t he operat ion of IP net works.
Conversely, t he client end of a connect ion t ypically uses a high port number allocat ed for
short -t erm use, t herefore called an ephemeral port .
The port numbers are divided int o t hree ranges: t he well-known ports , t he registered ports ,
and t he dynamic or private ports .
The well-known port s (also known as system ports ) are t hose numbered from 0 t hrough 1023.
The requirement s for new assignment s in t his range are st rict er t han for ot her regist rat ions.[2]
Number Assignment
80 Hypert ext Transfer Prot ocol (HTTP) used in t he World Wide Web
143 Int ernet Message Access Prot ocol (IMAP) Management of digit al mail
The regist ered port s are t hose from 1024 t hrough 49151. IANA maint ains t he official list of
well-known and regist ered ranges.[3]
The dynamic or privat e port s are t hose from 49152 t hrough 65535. One common use for t his
range is for ephemeral port s.
Network behavior
Transport -layer prot ocols, such as t he Transmission Cont rol Prot ocol (TCP) and t he User
Dat agram Prot ocol (UDP), t ransfer dat a using prot ocol dat a unit s (PDUs). For TCP, t he PDU is
a segment , and for UDP it is a dat agram. Bot h prot ocols use a header field for indicat ing t he
source and dest inat ion port numbers. The port numbers are encoded in t he t ransport prot ocol
packet header, and t hey can be readily int erpret ed not only by t he sending and receiving
host s but also by ot her component s of t he net working infrast ruct ure. In part icular, firewalls
are commonly configured t o different iat e bet ween packet s based on t heir source or
dest inat ion port numbers. Port forwarding is an example applicat ion of t his.
Port scanning
The pract ice of at t empt ing t o connect t o a range of port s in sequence on a single host is
commonly known as port scanning. This is usually associat ed eit her wit h malicious cracking
at t empt s or wit h net work administ rat ors looking for possible vulnerabilit ies t o help prevent
such at t acks. Port connect ion at t empt s are frequent ly monit ored and logged by host s. The
t echnique of port knocking uses a series of port connect ions (knocks) from a client
comput er t o enable a server connect ion.
Examples
An example of t he use of port s is t he delivery of email. A server used for sending and
receiving email generally needs t wo services. The first service is used t o t ransport email t o
and from ot her servers. This is accomplished wit h t he Simple Mail Transfer Prot ocol (SMTP).
A st andard SMTP service applicat ion list ens on TCP port 25 for incoming request s. The
second service is usually eit her t he Post Office Prot ocol (POP) or t he Int ernet Message
Access Prot ocol (IMAP) which is used by email client applicat ions on users' personal
comput ers t o fet ch email messages from t he server. The POP service list ens on TCP port
number 110. Bot h services may be running on t he same host comput er, in which case t he port
number dist inguishes t he service t hat was request ed by a remot e comput er, be it a user's
comput er or anot her mail server.
While t he list ening port number of a server is well defined (IANA calls t hese t he well-known
port s), t he client 's port number is oft en chosen from t he dynamic port range (see below). In
some applicat ions, t he client s and t he server each use specific port numbers assigned by t he
IANA. A good example of t his is DHCP in which t he client always uses UDP port 68 and t he
server always uses UDP port 67.
Use in URLs
Port numbers are somet imes seen in web or ot her uniform resource locat ors (URLs). By
default , HTTP uses port 80 and HTTPS uses port 443, but a URL like
http://www.example.com:8080/path/ specifies t hat t he web browser connect s
inst ead t o port 8080 of t he HTTP server.
History
The concept of port numbers was est ablished by t he early developers of t he ARPANET in
informal cooperat ion of soft ware aut hors and syst em administ rat ors. The t erm port number
was not yet in use. It was preceded by t he use of t he t erm socket number in t he early
development st ages of t he net work. A socket number for a remot e host was a 40-bit
quant it y.[4] The first 32 bit s were similar t o t oday's IPv4 address, but at t he t ime t he most -
significant 8 bit s were t he host number. The least -significant port ion of t he socket number
(bit s 33 t hrough 40) was an ent it y called Another Eightbit Number, abbreviat ed AEN.[5] Today,
network socket refers t o a relat ed but dist inct concept , namely t he int ernal address of an
endpoint used only wit hin t he node.
On March 26, 1972, Vint Cerf and Jon Post el called for document ing t he t hen-current usages
and est ablishing a socket number cat alog in RFC 322. Net work administ rat ors were asked t o
submit a not e or place a phone call, "describing t he funct ion and socket numbers of net work
service programs at each HOST".[6] This cat alog was subsequent ly published as RFC 433 in
December 1972 and included a list of host s and t heir port numbers and t he corresponding
funct ion used at each host in t he net work. This first regist ry funct ion served primarily as
document at ion of usage and indicat ed t hat port number usage was conflict ing bet ween
some host s for "useful public services".[5] The document promised a resolut ion of t he
conflict s based on a st andard t hat Post el had published in May 1972 in RFC 349, in which he
first proposed official assignment s of port numbers t o net work services and suggest ed a
dedicat ed administ rat ive funct ion, which he called a czar, t o maint ain a regist ry.[7] The 256
values of t he AEN were divided int o t he following ranges:
AEN ranges
The Telnet service received t he first official assignment of t he value 1. In det ail, t he first set
of assignment s was:[7]
1 Telnet
3 File t ransfer
7 Echo
9 Discard
In t he early ARPANET, t he AEN was also called a socket name,[8] and was used wit h t he Init ial
Connect ion Prot ocol (ICP), a component of t he Net work Cont rol Prot ocol (NCP).[9][10] NCP
was t he forerunner of t he modern Int ernet prot ocols. Today t he t erminology service name is
st ill closely connect ed wit h port numbers, t he former being t ext st rings used in some
net work funct ions t o represent a numerical port number.
References