Project 3 - The ping program

Introduction

This project is an extension of project 2 where a stub was provided for the Logical Link Control, LLC. In addition, the ARP, IP, and ICMP, protocols will be used in this project in order to implement the response to a ping request. This project is completed when the ping program receives the correct response to an ARP request, and ICMP echo replies in response to echo requests.

There is some administration in order to obtain the source code. Refer to the suggested design of the class hierarchy as well as advice on how to approach the completion of the skeleton code. An executable which may be loaded into the ETRAX unit is compiled, linked, and loaded in the same manner as in the previous overview of the system. Finally, you will have to test your solution.

Recommended reading

Read chapter 3, the internet protocol (IP), and 4, the address resolution protocol (ARP), as well as chapters 6 and 7, about ICMP and the ping program in [Stevens96]. Chapters 9, IP routing, and 10, dynamic routing protocols, are recommended reading as well although they are not essential for the implementation in this project. An ethernet frame description is presented in p.23.

Consult RFC826 on ARP, RFC791 on IP, and RFC792 on ICMP.

The ping program

The ping program is often used as a tool in order to find a diagnose to network problems. It tests whether another host is reachable by sending an ICMP echo request. First of all though, the program must

in order to send the echo request to the right destination.

The host name of the server implementation will be used instead of the IP address, e.g. the server godzilla has the IP address 192.168.10.60 and the ethernet address 02:67:01:04:02:37. When the command ping godzilla is executed on the host linus the address resolving depends on several steps.

An important observation is that the host godzilla does not know its name, just its IP and ethernet address. The association between the name and the IP address is performed locally by linus.

Suggested solution design

The figure shows the information flow both for a packet received and a packet transmitted. In the previous project, the class EthernetInPacket was implemented. The stub provided for the Logical Link Control, LLC, handled ICMP packets in a crude way and will be replaced in this project. In addition, ARP, IP, and ICMP will be partially implemented. The TCP part will be considered in the next project.

The class diagram below describes the design of the solution for the four protocols to be implemented in this project. Each class is defined in the header files llc.hh, arp.hh, ip.hh and icmp.hh, which are provided for guidance. The corresponding *.cc files are not provided and will contain the code implemented when the project is finished.

A container for the IP address is provided as the class IPAddress in the files ipaddr.[hh,cc]. These files also define and implement a function which calculates checksums, calculateChecksum.

 Details in the implementation

Big and little endian revisited

Remember, all protocols in TCP/IP are big endian whereas the ETRAX architecture is little endian. Thus, the opposite ordering of bytes in integers are used. The macro HILO solves the translation between the two endian formats. For example,

uword realPacketLength = HILO(anIPHeader->totalLength);
anIPHeader->totalLength = HILO(realPacketLength);

Only 16 bit integers are affected since integers only are interpreted in the sense of big or little endian. Other fields, e.g. the IP address and the ethernet address, are interpreted without being affected by the endian.
 
 No rule without an exception. The function calculateChecksum returns a result which is big endian, according to the network byte order, and should not be altered.

anIPHeader->headerChecksum = calculateChecksum((byte*)anIPHeader,
                                                IP::ipHeaderLength,
                                                0);

Memory leaks

A check of memory leaks (dynamically allocated memory not returned to the system) may be accomplished by a printout in the frontpanel class for example. Every time a LED blinks the total amount of memory left in the system may be printed with the statement

cout << "Core " << ax_coreleft_total() << endl;

The LLC layer

The ARP layer

The IP layer

 There are a number of issues to consider in the process of decoding an IP datagram.

The assembly of a reply packet is accomplished as follows.

ICMP

Source code, compilation, linking and loading

Make sure your present working directory is ~/kurs/src. Remove the subfolder lab3 if it exists in ~/kurs/src. Then, copy all files from your solution in project 2 with the command

cp -r lab2 lab3

and change your present working directory into ~/kurs/src/lab3. This project will be an extension of your solution in project 2. Add the skeleton of project 3 to your previous files with the command

cp -r ~inin/kurs/src/lab3/* .

There should be six files in addition to the ones from project 2 in the directory lab3,

The file llc.cc from project 2 will need modifications in order to replace the stub with functional code. In addition, arp.cc, ip.cc and icmp.cc must be created from scratch.

The target of the make process is defined in the file /kurs/make/lab3/modules. Make sure that your present working directory is ~/kurs/make and type the commands:

Testing the solution

The tools in this project are

The ping program is used in order to test the solution.

The ping-program has an option -s which sets the packet size to be transmitted. Try sending packets with various sizes from 4 to 1450 and make sure you understand which packet sizes are critical,

Test the behaviour of the ping program by executing the command ping print-1. It will show the response of a working IP stack if you are uncertain on what to expect. When everything is working in your server solution, the response in the terminal window will look the same.

Use the application Ethereal in order to detect what is sent on the network

Note that the ARP packets must be processed correctly in order to allow the ping program to send ICMP requests. Even if the ARP processing is working, the ICMP processing might be incorrect.