CPS 472/572:  Computer Networking

Project 1:  IP Decoder

Tuesday, January 7, 2003

Due:  Tuesday, January 21, 2003

Dr. Jennifer Seitzer

 

Description

Both network monitors and forwarding machines perform IP packet translation and interpretation by parsing a group of bits in a packet into the appropriate fields as specified in the IP protocol.

 

Write a computer program to automatically parse incoming IP packets.  The program should automatically extract all the fields of the IP header of the datagram as well as the Ethernet header in which the datagram is encapsulated, as was done manually in class. The IP source and destination addresses should be printed out in both hexidecimal and in dotted decimal notation.  In your parsing and translation, you should assume the following Ethernet and IP data unit structures. 

 

 

typedef     unsigned char     Eaddr[EP_ALEN];

                                    /* physical Ethernet address  */

 

typedef     unsigned long IPaddr;   /* internet address           */

 

struct      ep {              /* ethernet header                  */    Eaddr eh_dst;           /* destination host address         */

      Eaddr eh_src;           /* source host address              */

      unsigned short eh_type; /* Ethernet packet type             */

      char  ep_data[EP_DLEN]; /* data in the packet               */

};

 

 

struct      ip    {

      u_char      ip_verlen;  /* IP version & header length (in longs)*/

      u_char      ip_tos;     /* type of service                  */

      short       ip_len;     /* total packet length (in octets)  */

      short       ip_id;      /* datagram id                      */

      short       ip_fragoff; /* fragment offset (in 8-octet's)   */

      u_char      ip_ttl;     /* time to live, in gateway hops    */

      u_char      ip_proto;   /* IP protocol (see IPT_* above)    */

      short       ip_cksum;   /* header checksum                  */

      IPaddr      ip_src;     /* IP address of source             */

      IPaddr      ip_dst;     /* IP address of destination        */

      u_char      ip_data[1]; /* variable length data             */

};

Submission Requirements:

·          All  programs must be submitted in a  folder.  The folder should be properly identified on the outside areas with the following information: 
        1.  Last Name

                2.  First Name

                3.  Class Name and Number

 

·          A one to two page typed description explaining the program, your implementation, the algorithms you employed, your input and output files, and any difficulties you encountered in doing this project

·          A hard copy of  all source code with the first line indicating, by a comment, the name of the physical file in which the source code is located.

·          A hard copy of output from the program

·          A hand-drawn structure chart showing all subroutines (functions) and the functions they call.

          A program cover sheet STAPLED  to the source, output, structure chart.  This can be procured from the course website:  http://homepages.udayton.edu/~seitzer/cps472
        Note:  the paper should be stapled so that the documents are ordered as follows:

          Cover Sheet

1.        Written Description

2.        Program Source

3.        Program Output

4.        Structure Chart

¨        A labeled diskette with your name containing all source files (both .h and .cpp) ,  the generated output file, any input data files, and any output data files, and an executable.   Please DO NOT give me any other files on the diskette.

 

Sample Execution

Given the following Ethernet frame as input, your output should contain the following information.

(You may wish to format it differently.)

 

input:

d4 6e 07 00 01 00 3c 00 00 aa 00

a3 49 93 08 00 20 08 b7 82 08 00

45 00 29 00 21 96 00 40 10 06 80

0a 03 64 80 0a 03 65 e8 7a ff ff

80 61 c1 59 3c d5 be 65 53 e2 50

18 22 38 68 78 00 00 0d 08 69 6e

75 20

output:

 ETHERNET HEADER INFORMATION: 

          Ethernet Dest Host:                   00 aa 00 a3 49 93

          Ethernet Source Host:               08 00 20 08 b7 82               

          Ethernet Frame Type:             08 00

          IP PACKET HEADER INFORMATION: 

               IP Version :                             4

Packet Length:                      5

               Type of Service:                    00

               IP Packet Length:  29 00        

               Datagram ID:                          21 96

               Fragment Offset (8-octs):     00 40

               Time To Live (# hops):         10

               IP Protocol:                            06

               IP Header Checksum:           e8 78

               IP Source Host (hex):            80 0a 03 64

IP Source Host (dec):          128.10.3.100

IP Destination Host (hex):  80 0a 03 65

IP Destination Host (dec):  128.10.3.101

IP Header Checksum:          e87a       

 

IP PAYLOAD:

ff ff 80 61 c1 59 3c d5 be 65 53 e2 50

18 22 38 68 78 00 00 0d 08 69 6e 75 20