COMP2300 - HW1
COMP2300 / COMP6300
Home Work 1 - Computer Communications
Semester 1, 2009
Week 12 (25 - 30 May)
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.
Service Access Points (SAPs)
Recall from lectures that 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.
- 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.
- 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).
- 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.
- 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.
- 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>?
- 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.
- Type telnet bohm.anu.edu.au 25 and press
return.
- 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?
- Type expn u9999999 (where 9999999 is your
student number) and press return. What does the remote server
respond with?
- Type quit and press return to terminate the connection.
- A list of the network services defined on wallaman (or
partch), and
their corresponding port numbers, can be found in the file
/etc/services. Open this file in your favourite editor.
- What information are you likely to be able to get from the
service listening on port 37?
- 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.
- 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 wallaman (or 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 wallaman/partch to the ANU web server (www.anu.edu.au).
-
Trace the route to the CS web server (cs.anu.edu.au).
- 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.
- Use man pages to determine what each of the above functions do
- wallaman and partch are two machines on the student network. One
of these machines has the same byte ordering as network byte
ordering, while the other is different. Using one of the above
functions write a short (<10 line) C program to determine which
machine uses network byte ordering.
- 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).
- 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 |
- 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.
me@wallaman> ./hex2dd 0x8002c2f2
128.2.194.242
- Write a program dd2hex.c that converts its
dotted-decimal argument to hex and prints out the result
me@wallaman> ./dd2hex 128.2.194.242
0x8002c2f2
- Note that if you recompile and run these programs on an x86-based host
(use gcc -o hex2dd hex2dd.c),
you get different hex numbers generated. However, combining the
conversions should give the same result on either host:
me@either> ./hex2dd `./dd2hex 128.2.194.242`
128.2.194.242
Last modified: 20/05/2009, 12:04