Вы находитесь на странице: 1из 15

13/01/2019 TCP and UDP Ports Explained

Related: 3 hits streaming on Netflix this weekend

Home  Tutorials & Tech Support Guides  Internet Tutorials 101  


 TCP and UDP Ports Explained

TCP and UDP Ports Explained


Lawrence Abrams

March 24, 2004


Read 1,252,801 times
 

Introduction

In this tutorial we will discuss the concept of Ports and how they work with IP
addresses. If you have not read our article on IP addresses and need a brush up,
you can nd the article here. If you understand the concepts of IP addresses, then
lets move on to TCP and UDP ports and how they work.

The devices and comptuers connected to the Internet use a protocol called
TCP/IP to communicate with each other. When a computer in New York wants to
send a piece of data to a computer in England, it must know the destination IP
address that it woud like to send the information to. That information is sent
most often via two methods, UDP and TCP.

https://www.bleepingcomputer.com/tutorials/tcp-and-udp-ports-explained/ 1/15
13/01/2019 TCP and UDP Ports Explained

The two Internet workhorses: UDP and TCP

UDP? TCP? I know you are getting confused, but I promise I will explain this in
very basic terms so that you can understand this concept.

TCP stands for Transmission Control Protocol. Using this method, the computer
sending the data connects directly to the computer it is sending the data it to, and
stays connected for the duration of the transfer. With this method, the two
computers can guarantee that the data has arrived safely and correctly, and then
they disconnect the connection. This method of transferring data tends to be
quicker and more reliable, but puts a higher load on the computer as it has to
monitor the connection and the data going across it. A real life comparison to
this method would be to pick up the phone and call a friend. You have a
conversation and when it is over, you both hang up, releasing the connection.

UDP stands for User Datagram Protocol. Using this method, the computer
sending the data packages the information into a nice little package and releases
it into the network with the hopes that it will get to the right place. What this
means is that UDP does not connect directly to the receiving computer like TCP
does, but rather sends the data out and relies on the devices in between the
sending computer and the receiving computer to get the data where it is
supposed to go properly. This method of transmission does not provide any
guarantee that the data you send will ever reach its destination. On the other
hand, this method of transmission has a very low overhead and is therefore very
popular to use for services that are not that important to work on the rst try. A
comparison you can use for this method is the plain old US Postal Service. You
place your mail in the mailbox and hope the Postal Service will get it to the proper
location. Most of the time they do, but sometimes it gets lost along the way.

Now that you understand what TCP and UDP are, we can start discussing TCP
and UDP ports in detail. Lets move on to the next section where we can describe
the concept of ports better.

TCP and UDP Ports


https://www.bleepingcomputer.com/tutorials/tcp-and-udp-ports-explained/ 2/15
13/01/2019 TCP and UDP Ports Explained

As you know every computer or device on the Internet must have a unique
number assigned to it called the IP address. This IP address is used to recognize
your particular computer out of the millions of other computers connected to the
Internet. When information is sent over the Internet to your computer how does
your computer accept that information? It accepts that information by using TCP
or UDP ports.

An easy way to understand ports is to imagine your IP address is a cable box and
the ports are the different channels on that cable box. The cable company knows
how to send cable to your cable box based upon a unique serial number
associated with that box (IP Address), and then you receive the individual shows
on different channels (Ports).

Ports work the same way. You have an IP address, and then many ports on that
IP address. When I say many, I mean many. You can have a total of 65,535 TCP
Ports and another 65,535 UDP ports. When a program on your computer sends or
receives data over the Internet it sends that data to an ip address and a speci c
port on the remote computer, and receives the data on a usually random port on
its own computer. If it uses the TCP protocol to send and receive the data then it
will connect and bind itself to a TCP port. If it uses the UDP protocol to send and
receive data, it will use a UDP port. Figure 1, below, is a represenation of an IP
address split into its many TCP and UDP ports. Note that once an application
binds itself to a particular port, that port can not be used by any other application.
It is rst come, rst served.

Related: Top 10 Best Beard Trimmer List for Men - Nov. 2018 with Buying Guide

<-------------------- 192.168.1.10 -------------------->

0 1 2 3 4 5 .. .. .. .. .. .. .. .. 65531 65532 65533 65534 65535


Figure 1. IP address with Ports

This all probably still feels confusing to you, and there is nothing wrong with that,
as this is a complicated concept to grasp. Therefore, I will give you an example of
how this works in real life so you can have a better understanding. We will use
web servers in our example as you all know that a web server is a computer
running an application that allows other computers to connect to it and retrieve
the web pages stored there.

https://www.bleepingcomputer.com/tutorials/tcp-and-udp-ports-explained/ 3/15
13/01/2019 TCP and UDP Ports Explained

In order for a web server to accept connections from remote computers, such as
yourself, it must bind the web server application to a local port. It will then use
this port to listen for and accept connections from remote computers. Web
servers typically bind to the TCP port 80, which is what the http protocol uses by
default, and then will wait and listen for connections from remote devices. Once a
device is connected, it will send the requested web pages to the remote device,
and when done disconnect the connection.

On the other hand, if you are the remote user connecting to a web server it would
work in reverse. Your web browser would pick a random TCP port from a certain
range of port numbers, and attempt to connect to port 80 on the IP address of
the web server. When the connection is established, the web browser will send
the request for a particular web page and receive it from the web server. Then
both computers will disconnect the connection.

Now, what if you wanted to run an FTP server, which is a server that allows you to
transfer and receive les from remote computers, on the same web server. FTP
servers use TCP ports 20 and 21 to send and receive information, so you won't
have any con icts with the web server running on TCP port 80. Therefore, the FTP
server application when it starts will bind itself to TCP ports 20 and 21, and wait
for connections in order to send and receive data.

Most major applications have a speci c port that they listen on and they register
this information with an organization called IANA. You can see a list of
applications and the ports they use at the IANA Registry. With developers
registering the ports their applications use with IANA, the chances of two
programs attempting to use the same port, and therefore causing a con ict, will
be diminished.

--
Lawrence Abrams
Bleeping Computer Advanced Internet Concepts Tutorial
BleepingComputer.com: Computer Support & Tutorials for the beginning
computer user.

Users who read this also read:

IP ADDRESSES EXPLAINED

Every machine on the the Internet has a unique number assigned to it, called an
IP address. Without a unique IP address on your machine, you will not be able to
communicate with other devices, users, and computers on the Internet. You can
look at your IP address as if it were a telephone number, each one being unique
and used to identify a way to reach you and only you.

https://www.bleepingcomputer.com/tutorials/tcp-and-udp-ports-explained/ 4/15
13/01/2019 TCP and UDP Ports Explained

TRACING A HACKER

Have you ever been connected to your computer when something strange
happens? A CD drive opens on its own, your mouse moves by itself, programs
close without any errors, or your printer starts printing out of nowhere? When this
happens, one of the rst thoughts that may pop into your head is that someone
has hacked your computer and is playing around with you. Then you start feeling
anger tinged ...

UNDERSTANDING AND USING FIREWALLS

The Internet is a scary place. Criminals on the Internet have the ability to hide
behind their computers, or even other peoples computers, while they attempt to
break into your computer to steal personal information or to use it for their own
purposes. To make matters worse, there always seems to be a security hole in
your software or operating system that is not xed fast enough that could ...

ALL ABOUT NETWORKS

With so much of Computer use these days revolving around the Internet and
communicating with others, its important that you understand what exactly a
network is. Without networks, all communication between your computer and
other computers whether it be instant messaging, email, web browsing, or
downloading music could not be achieved. This tutorial will strive to teach you
about networks and ...

THE HOSTS FILE AND WHAT IT CAN DO FOR YOU

When using the Internet most people connect to web sites, ftp servers or other
Internet servers by connecting to a domain name, as in
www.bleepingcomputer.com. Internet applications, though, do not communicate
via domain names, but rather using IP addresses, such as 192.168.1.1. Therefore
when you type a domain name in your program that you wish to connect to, your
application must rst convert ...

COMMENTS:


BleepingComputer.com Comment Policy
Please read our Comment Policy before commenting.

https://www.bleepingcomputer.com/tutorials/tcp-and-udp-ports-explained/  5/15
13/01/2019 TCP and UDP Ports Explained
31 Comments BleepingComputer.com 
1 Login

 Recommend 46 t Tweet f Share Sort by Newest

Join the discussion…

LOG IN WITH
OR SIGN UP WITH DISQUS ?

Name

ariel campos • 7 months ago


Awesome. Thanks
△ ▽ • Reply • Share ›

Harry Choi • a year ago


Great explanation!
△ ▽ • Reply • Share ›

Ibbi Khan • a year ago


Thank you.
△ ▽ • Reply • Share ›

Comments continue after advertisement

Local McDonald's Employee in Tears After


₹9,60,59,693 Win
Spectacular Jackpot Instantly Changed Her Life

Learn More

Sponsored by Daily News

Shubham Mathankar • a year ago


its amazing explanation.. keep going on.. we r reading ur all
posts...
△ ▽ • Reply • Share ›

Matthew • a year ago


Excellent. Thank you
△ ▽ • Reply • Share ›

Joffer Factor • a year ago


VERY WELL explained! Good Job!
△ ▽ • Reply • Share ›
https://www.bleepingcomputer.com/tutorials/tcp-and-udp-ports-explained/ 6/15
13/01/2019 TCP and UDP Ports Explained

Raj Sharma • 2 years ago


very nice article. Thanks.
2△ ▽ • Reply • Share ›

Shaheena Kazi • 2 years ago


This was a very nice article.. 👍
1△ ▽ • Reply • Share ›

gagan.theroyal • 3 years ago


If I am communicating with a web server (e.g. Google server)
using UDP protocol, can this happen that Google server listens my
request on one port but replies to my request from another port?
2△ ▽ • Reply • Share ›

Comments continue after advertisement

Local McDonald's Employee in Tears After


₹9,60,59,693 Win
Spectacular Jackpot Instantly Changed Her Life

Learn More

Sponsored by Daily News

Reinko Rust • 3 years ago


So someone said he got my UDP. He also said he could open my
webcam and see everything. Is this possible?
3△ ▽ • Reply • Share ›

Colosso • 3 years ago


What does it mean to "bind" to a port? And what is a port, anyway,
physically? Is it a memory space? Or is it simply some concept
provided by some software driver? More clarification, please, thank
you.
3△ ▽ • Reply • Share ›

Aparna • 3 years ago


Very well explained!! Thanks for the post.
△ ▽ • Reply • Share ›

Sam • 4 years ago


This is otherwise a tough concept to understand and you have
explained it so well. Thanks for the post.
41 △ ▽ • Reply • Share ›
https://www.bleepingcomputer.com/tutorials/tcp-and-udp-ports-explained/ 7/15
13/01/2019 TCP and UDP Ports Explained

haI9000 • 4 years ago


Excellent explanation of how TCP and UDP work and their
differences. Would I be correct in assuming that an application like
Disqus uses UDP for posting comments on blog sites? or is there
some other protocol that loses characters or does not allow
characters to echo back to the users screen, like UDP can
sometimes do when physical and/or network layers sessions have
problems, e.g., timing issues, misconfigurations, defective ports,
patch cords, fiber and fiber splitters, etc.?
△ ▽ • Reply • Share ›

mido kamal • 4 years ago


Thanks for the nice explanation, it is really useful .. i have a
question about the ports and their uses. suppose am having a
server or device using a port other than 80 to serve a web page to
the internet ( say it is using port 2500). Can any user connect to
the web page that my server is serving using his internet browser
or he will need to specify something else to do that ??
i couldnt check that because my internet provider is not allowing
me to use any ports other than 80 !!

thanks ..
5△ ▽ • Reply • Share ›

Comments continue after advertisement

Local McDonald's Employee in Tears After


₹9,60,59,693 Win
Spectacular Jackpot Instantly Changed Her Life

Learn More

Sponsored by Daily News

Tarun Das • 5 years ago


If I have to connect to a svn server on port 3690 do I need to have
my hone computer's same port (i.e. 3690) open ? Or it will get
connected to a random open port of my home computer?
△ ▽ • Reply • Share ›

Lawrence Abrams Mod > Tarun Das • 5 years ago


No you do not need to open the port on your end unless
your local computer is the server.
1△ ▽ • Reply • Share ›

David Chandler > Lawrence Abrams • 4 years ago


https://www.bleepingcomputer.com/tutorials/tcp-and-udp-ports-explained/ 8/15
13/01/2019 TCP and UDP Ports Explained
David Chandler > Lawrence Abrams • 4 years ago
LAWRENCE, thanks for a well explained topic.
My Question is: I believe that YouTube serves these
UDP packets to me, then dis-continues to serve the
remainder of my chosen video before it is
completed. VERY FRUSTRATING. If i shut the UDP
FUNCTION OFF will my internet service still
continue to work..? Put simpler, Is there a down side
to phoning in all of my connections & Stop using the
U.S. mail service ports all together.?
△ ▽ • Reply • Share ›

Anestis • 5 years ago


So when a web server listens on port 80, that means TCP port 80?
Meaning I can have a different application listen on UDP port 80?
And if that's the case and udp ports are completely isolated to tcp
ports how come some port scanners use udp packets for their port
scans? Wouldn't that mean that they could only scan open udp
ports and not tcp ports?
31 △ ▽ • Reply • Share ›

michael • 5 years ago


I am a radio amatuer and trying to set up Echo link using TCP and
UDP, could I use TCP on inbound as well as outbound ?? I know
Echolink wants outbound TCP 5200 and inbound 5198 and 5199,
not sure why.
△ ▽ • Reply • Share ›

hawkenfox > michael • 4 years ago


I think it's full duplex (meaning you can sent and receive at
the same time) so you will need incoming and out going
port at the same time, hence 2 ports or more.
△ ▽ • Reply • Share ›

humpity • 6 years ago


When I make a phone call, the other person speaks back to me on
the same line. Is this true with TCP ? Is the port 80 having data go
both ways?
4△ ▽ • Reply • Share ›

Lawrence Abrams Mod > humpity • 6 years ago


Yes, TCP is a connected session. It requires two
connections to be actively connected. UDP on the other
hand sends the packets out and hopes it gets there.
1△ ▽ • Reply • Share ›

https://www.bleepingcomputer.com/tutorials/tcp-and-udp-ports-explained/ 9/15
13/01/2019 TCP and UDP Ports Explained

disqus_A2JcJ302v0 • 6 years ago


good article..well explained sir...
1△ ▽ • Reply • Share ›

Munendra P • 7 years ago


Thank u...its useful for me
△ ▽ • Reply • Share ›

Aaron Yankey • 7 years ago


Very helpful article.

△ ▽ • Reply • Share ›

carlo cua • 7 years ago


thanks for this article its very helpful :)
1△ ▽ • Reply • Share ›

Bakari Said • 7 years ago


THANKS SIR I GET SOMETHING IN YOUR TUTORIAL
1△ ▽ • Reply • Share ›

Derrick R Wright • 7 years ago


Thank you very much, this was a very good illustration of a topic
that can be very challenging and intimidating.
2△ ▽ • Reply • Share ›

Rashed • 7 years ago


thank u Sir it is very helpful article for us.
△ ▽ • Reply • Share ›

Tarun Das > Rashed • 5 years ago


If I have to connect a svn server on port 3690 do I need
have my hone computer's same port (i.e. 3690) open ? Or it
will get connected to a random open port of my home
computer?
△ ▽ • Reply • Share ›

✉ Subscribe d Add Disqus to your siteAdd DisqusAdd


🔒 Disqus' Privacy PolicyPrivacy PolicyPrivacy

https://www.bleepingcomputer.com/tutorials/tcp-and-udp-ports-explained/ 10/15
13/01/2019 TCP and UDP Ports Explained

blog comments powered by Disqus


SEARCH
TUTORIALS

Enter keywor Sear

JDCR believes that Armor King's damage


can be ridiculous, but is hurting from on...
EventHubs

TUTORIALS
NAVIGATION

Tutorials Home

New Tutorials

Popular
Tutorials

RSS Feed

https://www.bleepingcomputer.com/tutorials/tcp-and-udp-ports-explained/ 11/15
13/01/2019 TCP and UDP Ports Explained

RECOMMENDED
VIDEOS

macOS Bug Let's Take a


Demo of No Look at the

macOS High Anti-Israel


Sierra Bug IsraBye Data

Unwanted Add
Chrome Extension to

VIEW MORE

Cleveland Browns: Josh McDaniels, Dan


Campbell betting favorites for HC
dawgpounddaily

LATEST TUTORIALS

How to Enable
the Dark Mode
Theme in
Windows 10
LAWRENCE
ABRAMS

https://www.bleepingcomputer.com/tutorials/tcp-and-udp-ports-explained/ 12/15
13/01/2019 TCP and UDP Ports Explained

How to Change
Your Twitter
Password
LAWRENCE
ABRAMS

How to Setup
Login
Veri cation in
Twitter
LAWRENCE
ABRAMS

How to Use
Cortana As Your
Virtual
Assistant in
Windows
LAWRENCE
ABRAMS

Restrict What
Personal Data Is
Shared on the
Facebook API
Platform
LAWRENCE
ABRAMS

https://www.bleepingcomputer.com/tutorials/tcp-and-udp-ports-explained/ 13/15
13/01/2019 TCP and UDP Ports Explained

A New DUNGEONS & DRAGONS


Supplement Is Focused Entirely on
Warlocks
geektyrant

Related: 9 Major EDM Albums To Look Forward To In 2019

NEWSLETTER SIGN UP

https://www.bleepingcomputer.com/tutorials/tcp-and-udp-ports-explained/ 14/15
13/01/2019 TCP and UDP Ports Explained

Email Address... SUBMIT

Follow us:     

MAIN SECTIONS
News
Downloads
Virus Removal Guides
Tutorials
Startup Database
Uninstall Database
File Database
Glossary
COMMUNITY
Forums
Forum Rules
Chat
USEFUL RESOURCES
Welcome Guide
Sitemap
COMPANY
About BleepingComputer
Contact Us
Advertising
Write for BleepingComputer
Social & Feeds
Changelog

Terms of Use - Privacy Policy

Copyright @ 2003 - 2019 Bleeping Computer® LLC - All Rights Reserved

https://www.bleepingcomputer.com/tutorials/tcp-and-udp-ports-explained/ 15/15

Вам также может понравиться