views:

1521

answers:

11

What is the difference between a port and a protocol?

+14  A: 

A protocol is an agreement on how to interpret data and how to respond to messages. They generally specify message formats and legal messages. Examples of protocols include:

A port is part of socket end point in TCP and UDP. They allow the operating system to distinguish which TCP or UDP service on the host should receive incoming messages.

The confusion generally arises because, a number of ports are reserved (eg. port 80) and are generally listened to by severs expecting a particular protocol (HTTP in the case of port 80). While messages send to port 80 are generally expected to be HTTP messages, there is nothing stopping an non-HTTP server from listening on port 80 or an HTTP server from listening on an alternative port (for example 8080 or 8088).

Aaron Maenpaa
+25  A: 

Protocol = how to communicate, Port = where to communicate

Kent Boogaart
"Where" in the case of TCP/IP being an arbitrary number. Most common applications that use TCP/IP (web, email, ftp) use "well-known" ports (i.e. 80, 25, 21 respectively.)
Dave Swersky
A: 

A port is just a channel that you select for the communication, and the protocol determines how the communication is done. A certain protocol usually uses a specific port, like port 80 for HTTP, port 21 for FTP.

Guffa
+5  A: 

Port = Place where ships come in
Protocol = How the cargo is loaded on the ship

EBGreen
Unexplained analogies don't help when someone's confused.
Rob
So vote it down.
EBGreen
Actually, it depends on the reason they're confused. If they're just confused because they need an idea of what role the items play in order to get some context, an analogy can help quite a bit.
Beska
+2  A: 

A protocol is a description of how data is exchanged between systems, usually documented in an RFC document.

For IP networks, a port is a 16-bit number representing a particular service end-point on a server.

Where confusion may arise is that most protocols have a standard port on which they run (i.e. HTTP is usually run on port 80). However that's just convention and isn't mandatory in most cases.

Alnitak
+1  A: 

A protocol is a specification for how two devices should exchange data in a way that they can both understand. A port is kind of a numbered 'tag' that helps a computer decide who should receive an incoming piece of data.

Many protocols have a port that they run on by default; this makes it easier to discover them or configure applications that use them. But that's not a hard rule; they could always listen on a different port, as long as anyone contacting them knew about the change.

DNS
+54  A: 

You can think of a port as a phone extension, with the computer's IP address being like its phone number. You can call the number (IP address) to talk to the computer, then dial the extension (port) to talk to a specific application. An application needs to be listening on a port in order to communicate.

A protocol is just the language that the two applications on either end of a conversation agree to speak in. If your application is sending streams of bytes to my application, my application needs to know how to interpret those bytes.

Bill the Lizard
I like the phone extension metaphor, i bet it's common, but i never heard it before
MahlerFive
I read it back in college, so it's probably pretty common. I'd give proper credit if I could remember which book.
Bill the Lizard
You can keep the telephone analogue for protocol as well. The protocol would be the convention used to communicate, such as beginning the conversation with "Hello, this is Bill the Lizard".
Christoffer
A: 

Everyone is right: my favorite analogy is the one of the ships. Port: where cargo is loaded, Protocol: how the cargo is loaded/unloaded.

This wikipedia article might help you a little.

http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers

EllaJo
+1  A: 

ports = ears, mouth, eyeball, touch
protocols = English, Spanish, Sign Language, Braille

jms
A: 

in Simple port means to whom you communicate. & Protocol means how to communicate or way of communication.

Ramesh Singh
A: 

Protocol number :- The protocol number is a single byte in the third word of the datagram header. The value identifies the protocol in the layer above IP to which the data should be passed. Port Numbers/Port Address After IP passes incoming data to the transport protocol, the transport protocol passes the data to the correct application process. Application processes (also called network services) are identified by port numbers, which are 16-bit values. The source port number, which identifies the process that sent the data, and the destination port number, which identifies the process that is to receive the data, are contained in the first header word of each TCP segment and UDP packet. atul malviya bhopal

atul