Wednesday, April 20, 2016

Brief description of Ports numbers, MAC addresses, IP addresses



Brief Description:

Port number is used to identify an application/services which you want to talk to on your system. Some predefined ports like 80 = HTTP server, 23 = Telnet.

You identify a host uniquely (globally) by its IP address. So if I ever wanted to access your laptop via telnet then I'd use the IP address given to you by your ISP and the port 23 (more on this later).

You cannot contrast MAC addresses with port number directly. With MAC addresses you can uniquely identify a network card.

But you must be wondering how these things fit together!
More Details:


You first need to understand the significance of abstraction in networking. You build things on top of some other things. You don't worry about how things are done below you.

Say you want to get a webpage from Google.

  1. You say to the IP layer that connect with Google's IP address and give this packet to port 80 on the other side (Google's web server). You don't worry how it is delivered.. the IP layer could even use pigeons to transport your packet after them out. But you don't care, you just wait for the response (you do have a timeout).
  2. But the IP layer doesn't use pigeons. You packet first needs to go out of your home network. Your IP layer doesn't know how. This is where MAC addresses come into picture.
  3. Your link layer will talk to other link layers figure out how to dispatch the packet out of this subnetwork by using a protocol (language) called ARP. This is done via "Who has <IP Address>?" kind of a packet.
  4. One you know how to get out of this subnetwork (you figure your gateway) you'll hand over your packet through the link layer again to that particular host.
  5. There are intermediate hosts called routers which will try to move your packets from your gateway to Google's server. And finally the packet passes from Google's web server's link layer to IP layer. Then the web server's IP layer figures out which service to give the packet to and finally gives the packet to port 80 listening there.
  6. And finally the response comes back similarly.

* Step 3 is not done everytime. Once you figure out who's who (MAC address to IP mapping) you cache them and use it instead.

No comments:

Post a Comment