understanding the role of ports and TCP traffic is important when configuring uh network settings on your computer and when troubleshooting network problems that might arise so here we're going to look at a simple scenario uh where packets are traveling from a client computer through firewalls and two web and post office services so we've got a couple computers here and we're going to call one of the computers John and that simply represents a port number like 142. 23 so I'll just make up some type of address here and it's going to Fred so I'm just going to use John and Fred instead of an IP address port numbers uh represent where the packets are coming from what applications they're coming from and what they're going to well-known port numbers like 80 and 110 uh are standardized and Port 80 represents an HTTP protocol which is used by Web Services Port 110 is used by pop Services now typically when a packet goes out it has a IP address and it has a port number attached to it together this is called a socket and you need both for communications and we're going to show why we need both uh we're going to represent this instead of using numbers we're just going to um indicate the IP address of where it's going to and we're going to represent the service that it's going to in a packet so this would be the addressing we're going to use so the IP address is used to um is used to identify what computer we're sending to or from and the port represents what application or service we're sending to and from so let's take a look at how this works so John wants to has opened a Chown browser Chrome browser and a mail application and wants to uh retrieve a web page from Fred the server so one of the first things that has to happen is the Chrome browser is going to make a request and what we have are two firewalls in between here now by default firewalls are generally configured to allow outgoing uh traffic you can configure firewalls to block it but generally they're going to let traffic go out through a computer because the firewall is assuming you want traffic to go out when you have set up on a server when you set up a service like a web service um you need to make sure that traffic coming into the firewall uh is allowed through so a web service is going to open up what are called ports or holes through the firewall so a web service uh that uses HTTP or Port 80 is going to allow traffic coming in that has a designated port address of 80 and the post office uh is using the pop protocol or 110 so it's going to open up another Port through here so here we've opened up two ports through our firewall you need to maybe do that manually in man ual firewall configuration but often when you install these Services they open up those ports automatically so we're going to go back to John here and John is going to create a packet and as part of the packet uh the addressing is the first part of the information so we've got a to field and a from field uh where this packet is going to and who it's coming from so we're sending this packet to Fred the server and we're sending it to the web service and that's the well-known Port 80 or HTTP so that addressing information goes at the front of the packet and it's coming from John and the port we're coming from uh is not a well-known Port it's an application so generally applications just pick a random Port that's not being used above a th000 so we're just going to pick a th now it's important that we have a port that we're coming uh from because when traffic comes back we're going to use that number uh to find out which application we're going to send the return information to So eventually this is going to get return information and it needs to know the computer needs to know should I send this to the mail app which is open or should I send it to the browser app which is open so that traffic is going to go out through the computer and it's going to go through my firewall which allows everything to go out it's going to be carried through my internet here and it's going to hit this firewall now at this point this traffic is called unsolicited traffic and it's unsolicited because Fred did not know this traffic was going to happen however so the firewall inside Fred looks and says okay it's addressed to Fred that's fine and it's using HTTP well that's one of the things I allow so it comes in through the firewall and it uses the information in the port HTTP to say Ah that's for the web server so I'm going to direct it to that piece of software there now Fred processes that it's an uh request for a web page and so Fred is going to generate a return packet with the information in it okay and as far as the two field of the packet that's generated it's going to go to John because this came from John and it's going to go to Port 1000 because that's the application that requested this information it's coming from Fred and it's coming uh from http and then in the rest of the package is actually the data the information which is being requested which would be the web pages and the graphics and all that information so that traffic is going to go out through my firewall because my firewall allows everything to go out it comes here and now it hits this firewall now at this point the firewall inspects it and says Ah this is now solic ited traffic because John sent a request out earlier to Fred from Port 1000 and now this is the traffic back to JN using that same port 1000 so this firewall allows this traffic to come through because it's solicited we generally do not need a firewall rule um to allow solicited traffic back in in fact we would need a a Special Rule if we don't want it back in but generally that's not that's not the case this computer then looks at that packet and says Ah this is going to Port 1000 well I know that uh Chrome generated uh earlier packets from Port 1000 so it knows to send it to the Chrome browser as opposed to the email application now later pick another color here our email application is going to do the same thing John is going to request to retrieve some emails so the mail is going to generate a packet out through the firewall it's going to go through Fred but now the protocol is pop actually pop three because POP 3 is the current level of that pop standard Port 110 from John but now it uses a different port number just pick a random one uh and using the pop protocol and protocol just means rules uh there are some instructions in here basically saying I want to get stuff from this mailbox in my um in my post office box so this gets carried out again through the internet it hits the firewall as unsolicited traffic however it's not doesn't come in through the firewall through the port 80 that's open but it comes through the pop because pop also has an open port and it comes through here and because it's using Port 110 the pop Port it gets delivered to the post office the post office retrieves the mail sender sends it back to John on Port 1100 because that's where um the from information was from in the originating request goes out through here hits the firewall again solicited traffic it's using Port 1100 which was generated by mail and Comm back through here because these two ports are open over here we call this uh the web service is actually listening on Port 80 so sometimes you'll hear these two these terms used or it's listening on the HTTP Port so we have a firewall over here it has two ports which are called open and there are two Services which are listening on those ports the web service is listening on Port 80 and the post office is listening on Port 110 or the pop Port so that's a little bit how ports and TCP addresses are used together uh to send information from applications through the internet to another computer uh to a service and then back again