How does a network card make a port (for example port 80 for http)?

1.61K views

I don’t understand how a network card or even the software on a network card can make a virtual port and then make sure that traffic is processed alongside every other port. What are these ports actually and how do they work. literally not the same repeated stuff I find on every website when I search “what is a port” i’m looking for a much more in depth understanding.

In: Technology

6 Answers

Anonymous 0 Comments

Networking is divided into “layers”. Ports are part of TCP, which is one of the top “layers” of networking.

For the purposes of this discussion, the layers we’re interested in are Ethernet, IP and TCP. Also, for the purposes of this discussion, everything is a “computer”, regardless of what it does or how powerful it is. Also, all data travels as “packets”, which are blobs of about 1000 bytes of information.

Ethernet is responsible for getting a packet from one computer to a computer it is directly connected to with via a cable. The details here aren’t super important, but Ethernet is how data travels a single “hop” within a network. There are a bunch of other protocols that can do this, too, but Ethernet is almost certainly what any wired connection in your house uses.

But for computers to talk across a network, a packet will generally have to travel across several “hops”. The Internet Protocol, or IP, is how that happens. When you send a packet, you include an IP address. The computers within the network are clever enough to look at the IP address and “route” the packet through the network to its destination. Essentially, an IP address is a number used to identify *which computer this packet should be delivered to.*

Cool, so using IP, we can get any packet we want to any computer we want. But there’s a problem. I have a computer that I’ve set up to be a Minecraft server, but I’m also using the same computer to run my TeamSpeak server, so we can all talk to each other as we play. When my computer sends a packet to the server, how will the server know whether that packet is meant for Minecraft or TeamSpeak?

The answer is *port numbers*. If an IP address identifies a computer, a port number identifies which program running on that computer that packet is for. This is part of what TCP does. When my computer wants to send a command to the Minecraft server, it just tags it with the “port number” 25565. When my computer wants to send a query to the TeamSpeak server, it tags it with “port number” 10011. That way, the server can sort out which packets are for which program.

A program doesn’t have to “make a port.” When a program starts up, and it wants to accept incoming network traffic, it just says, “Hey, operating system, if any info comes in labeled ‘port 80’, can you please send it my way?” If no running program already has dibs on that port, the OS can say, “Sure thing.” Now, any packets that arrive at the computer with that port number get delivered to the correct program.

There’s a very good analogy to this with the postal system. A packet in a network is like an envelope in the postal system. The street address on the envelope identifies a specific house, just like an IP address identifies a specific computer. The name on the envelope identifies a specific recipient within the house, just like the port number identifies the specific recipient within the computer.

The idea of “a port” is kind of misleading. It’s just a numeric tag on a packet.

You are viewing 1 out of 6 answers, click here to view all answers.