Showing posts with label Networking. Show all posts
Showing posts with label Networking. Show all posts

Saturday, June 27, 2009

How URLs Work

Uniform Resource Locators (URL), you know: www.google.com, www.amazon.com, etc. Believe it or not these strings of text hold a lot of information about the structure and design of the site you are connection to. URL are really paths which go down the file structure (like /home/mike/
or c:\windows\, more on this latter) to the resource (file in most cases) that you are remotely accessing. When you type www.twitter.com in your browser you are tell the site, the path of the resource you want to access.

The format of URLs are a bit odd (according to Wikipedia the creator of URLs, Tim Berners-Lee, regrets the format) . You see, it follows a reverse order before the first /. Lets break down an URL to illustrate how an URL works. Take this URL for an example:

http://comp-phil.blogspot.com/2009/06/using-just-addition-and-negation-to.html

The first part http:// says which Internet protocol you are using to access the site (other popular examples are ftp:// and https://). Every browser I have ever used assumes if you just type www.vanguard.com that want to use HTTP so it will prefix http:// to your URL.

The next part, comp-phil.blogspot.com, is a bit odd. You see it is backwards, the way it is parsed is from the last . (dot) to first . (dot)., comp-phil.blogspot.com, looks like this /com/blogspot/comp-phil to the web server you are connecting to.



The image above shows how (on a very small scale) the Internet is organized. The com tells the DNS server which branch of the Internet the site is on (org, gov, net, uk, etc.). The next part, blogspot, tells you which domain branch the site is on. In this example the comp-phil says which sub-domain the site is on. Last, the www says (basicly) that the sub-domain is www (World Wide Web). So, the example can be thought of as /com/blogspot/comp-phil/www/. There is an implied .:80 at the end of this section, so this section of the URL really looks like www.comp-phil.blogspot.com.:80, if you do not believe me try www.google.com.:80 in your browser, I'll wait. Welcome back, the . (dot) after the com, says that it is the root directory (think UNIX directory structure), the :80 at the end says that the server is listening to port 80. Port 80 is the IANA assigned port number for the World Wide Web HTTP (web sites).

The last section of the example, /2009/06/using-just-addition-and-negation-to.html, is just the directory structure from the server's sub-domain to the resource you are requesting. If you look on the server you would see that in the /2009/06/ directory of the sub-domain a HTML file called using-just-addition-and-negation-to.html.

That's it, not very comlicated at all (well the www.comp-phil.blogspot.com part is complex, but understandable). Next time you type in www.twitter.com/MikeMKH in your browser you will understand what you really doing (and while you are there follow me and say hi).

Wednesday, June 24, 2009

UDP is Important

UDP (User Datagram Protocol) is a protocol which allows systems to send information. UDP is the quick and dirty way to transfer information, it does not use hand shakes (like TCP), it simply fires-and-forgets. Messages send by UDP are said to be transaction oriented, meaning that delivery and duplication protection are not guaranteed. This means that by using UDP to send a message anywhere from 0 to infinite amount of the same message maybe received by the receiver.

Often it is taught in school to think of UDP as junk mail, a junk mailer normally does not care if a piece of junk mail arrives at a home, instead the junk mailer cares about getting out a lot of mail at low costs. I prefer to think of UDP as an elderly man that does not have a good memory, often times this man will tell stories not knowing that they he has already told this story to the listener. The old man wants to convey some type of message (we hope), and to do this he tells a story. A young man listens to the story and normally will be polite (we hope) and allow the old man to tell the story even if he has already heard it. The old man could be thought of as UDP and the story as the packet being delivered. In this example the stories can be told to the young man 0 to infinite amount of times (we hope not infinite).

So, what good is UDP and why is it important? Well sometimes in order to save bandwidth and time a system will opt to use UDP over other protocols (like TCP) in order to transfer information. This is often used in application where a lot of data is being sent but if packets are lost or duplicated it is no big deal. Streaming media is an example of an application that would use UDP, most user are willing to accept a few blups in their Dramatic Chipmunk streaming video or their streaming "Beat It" by Michael Jackson on Grooveshark.

So why is UDP important? Well UDP is the protocol used by DNS (Domain Name System). So why is DNS important, well DNS is what allows you to use the internet. DNS translate the URL http://comp-phil.blogspot.com/ into 74.125.95.191 which is the IP address of comp-phil.blogspot.com. If it wasn't for DNS you would have to type in 72.21.210.250 every time you wanted to buy a book from Amazon. So you can say that UDP is important because DNS is import and DNS uses UDP.