CECS Home | ANU Home | Search ANU
The Australian National University
ANU College of Engineering and Computer Science
School of Computer Science
Printer Friendly Version of this Document

UniSAFE

Introduction to Computer Systems

Tutorial Laboratory 09 - Computer Communications

Week 11


Objectives

  • To give you some understanding of what occurs behind the scenes when you use Internet services such as email and the world-wide-web (WWW).
  • To understand the significance of big and little endian.

There is no preperation or tutorial questions this week. Note this is your last chance to get any of the labs marked off. So it may be worth going through some of this before the lab so you don't run out of time during the lab.

Service Access Points (SAPs)

When an application, such as a web browser, wants to access a network service on another computer (e.g. to request a web page stored there), it must know both the address of the remote computer and the service access point (SAP) for the service on that computer.

On Unix-based computers, SAPs are traditionally called port numbers, and are simply a positive integer number. Most web servers (the applications which serve web pages to web browsers) listen on port 80. In this first exercise we will use telnet (a very simple program which allows you to connect to other computers and interact directly with network services) to connect to a web server and you will manually fetch a web page.

  1. In a terminal window, type telnet  alto.anu.edu.au  80 and press return. This opens a connection to the web server application listening on port 80 on the remote machine called alto.anu.edu.au.

  2. The remote machine should respond by telling you its name and what the escape character is (you don't need to use the escape character, so don't worry about it).

  3. Request a web page by typing the following exactly as it appears:

        GET   /index.html   HTTP/1.0

    You have to press return twice to get a response.

  4. The web server you are connected to should respond with several header fields (e.g. the current date and time, the modifcation date and length of the web page, etc.) followed by the contents of the file.

  5. Use Mozilla to view the same page. The URL is:

    http://alto.anu.edu.au/index.html

    What happened to the HTML tags <br>, <p>, and <hr>?

  6. In Mozilla, look at the Page Info window (accessed via the Tools menu). Which fields of Page Info come from the header fields the web server sends?

We will now look at other network services operating on different port numbers.

  1. Type telnet  bohm.anu.edu.au  25 and press return.

  2. Give the remote machine a few seconds to reply, then read its response. What type of network service (e.g. web, FTP, electronic mail, GOPHER) is listening on port 25?

  3. Type expn  u9999999 (where 9999999 is your student number) and press return. What does the remote server respond with?

  4. Type quit and press return to terminate the connection.

  5. A list of the network services defined on partch, and their corresponding port numbers, can be found in the file /etc/services. Open this file in your favourite editor.

  6. What information are you likely to be able to get from the service listening on port 37?

  7. What port number does the talk service use?

    [Note that not all defined services are actually provided.]

Network Routing

For messages intended for remote computers to go beyond the local area network (LAN, sometimes called a subnet), the information packets which make up the message need to be passed from computer to computer. If a computer is a member of more than one local area network, it can be used to route the message from one of its LANs to another. For example, if A and C are on different LANs, but B is on two LANs, one with A, and another with C, then A and C can communicate if B is willing to pass the messages back and forth. Similarly, if C shared another LAN with D, then A and D could communicate via B and C.

  1. You can use the traceroute command to determine which computers messages will pass through to get to a particular destination. In a terminal window on partch, try the following command:

        traceroute   www.anu.edu.au

    It may take a few seconds to finish, but when it has, you should be able to look at the first two columns to see the names of the machines that messages will pass through to get from partch to the ANU web server (www.anu.edu.au).

  2. Trace the route to the CS web server (cs.anu.edu.au).

  3. Now do the same for the following machines:

        leonard.anu.edu.au
        library.anu.edu.au
        anusf.anu.edu.au

    You can check out the various ANU subnets at the network services web site

IP Addresses

An IP address is an unsigned 32-bit integer. Because internet hosts can have different host byte ordering (remember talking about big and little endian machines!) TCP/IP defines a uniform network byte ordering. Unix provides functions htonl(), htons(), ntohl(), ntohs() to convert between network and host byte order.
  1. Use man pages to determine what each of the above functions do
  2. partch is a machine on the student network. Using one of the above functions to write a short (~10 line) C program to determine which byte ordering this machine uses.
  3. Is network byte ordering big or little endian?
IP addresses are typically presented to humans in a form known as dotted-decimal notation, where each byte is represented by its decimal value and separated from the other bytes by a period. Internet programs convert back and forth between IP addresses and dotted decimal strings using the functions inet_pton() and inet_ntop() (where n denotes network representation, while p denotes application representation).
  1. Complete the following table (assuming network byte ordering):

    Hex Address Dotted-decimal address
    0x0  
    0xffffffff 
    0xef000001 
     205.188.160.121
     64.12.149.13
     150.203.24.4

  2. Write a program hex2dd.c that converts its hex command line argument to a dotted-decimal string and prints out the result. Hint: use the "%x" format specifier in sscanf(), consulting the man pages for this function and inet_ntop(). You can compile it with gcc -o hex2dd hex2dd.c -lnsl.
        $ ./hex2dd 0x8002c2f2
        128.2.194.242
        
  3. Write a program dd2hex.c that converts its dotted-decimal argument to hex and prints out the result
        $ ./dd2hex 128.2.194.242
        0x8002c2f2
        
  4. Note that if you recompile and run these programs on a system with different endians, you get different hex numbers generated. However, combining the conversions should give the same result on either host:
        $ ./hex2dd `./dd2hex 128.2.194.242`
        128.2.194.242