TCP/IP and GIF file size calculations

Finding your IP and other adventures

Find your computer's IP address using the http://www.whatismyip.com/ program:

The sequence you get is represented in the IPv4 system using 4 decimal numerals from 0 to 255. Is this conforming with what you got?

What is the maximum number of IP addresses you can have in this IPv4 system?

How many bits does the IPv4 requires?

Use http://www.whatismyip.com/tools/ip-address-lookup.asp to find the Latitude and the Longitude of your current location:

GET your personal site's HTML file using HTTP

Find and launch the Terminal application.( On a Mac go to the Spotlight in the upper right corner and type "Terminal").

In the terminal window that will appear, type telnet cs.wellesley.edu 80 to establish a connection to our server.

Next, type GET /~mir/index.html HTTP/1.0 and hit return twice to receive the main page of the CS department. What do you observe? Where is it redirecting?

Next, open the Telnet connection again, type HEAD /~mir/index.html HTTTP/1.0 and hit return twice, what do you get?

What is the URL of your site?

Use the same procedure as above to fetch the main HTML file of your personal web page. Save its contents on a file in the desktop and open it in a browser! What is missing?

Now let's try a persistent connection

Type telnet www.apache.org 80 to establish a connection to apache.org

Next, type HEAD / HTTP/1.1, hit enter once Now, type Host: www.apache.org and hit enter twice. What do you get?

Note that HTTP 1.1 needs the Host name.

Image formats on the Web and GIF file calculations

Most of the times, the images you see on the Web are in one of the following formats: jpeg and gif (and sometimes in png). These formats differ on the algorithms they use to compress the file.

File calculation for GIF format

GIF is also known as "index color". A gif image can only have up to 256 colors. (That makes this format unsuitable for some categories of images, like photographs.)

Here is how GIF compression works:
The color of each pixel in a gif image is mapped to a number from 0 to 255.

So, for example,

A mapping table is also created that holds the relationship of each index to the real color, something like this:

There are 200 x 400 = 80000 pixels total
Using 2 bits for each pixel (since 2 to the 2 is four, i.e. with 2 bits we can represent 4 numbers, which is exactly the number of colors we need for the image)
So: 80000 pixels x 2 bits/pixel = 160000 bits = 160000/8 Bytes = 20,000 Bytes or 19.53KB

Also we would need some space for the mapping table, but let's do not worry about it here. It is not too large.

If an image contains more colors, then we need more bits per color, to be able to index all of them.

Tasks