|
@@ -100,33 +100,32 @@ The task of the sniffer programmer to decode the raw stream into human readable
|
100
|
100
|
|
101
|
101
|
#### Instructions:
|
102
|
102
|
|
103
|
|
-1. To load this project you need to run QtCreator with administrator (root) privileges.
|
104
|
|
-`sudo qtcreator Documents/eip/classes-simplesniffer/SimpleSniffer.pro`
|
105
|
103
|
|
106
|
|
-2. Load the project `SimpleSniffer` into `QtCreator`. There are two ways to do this:
|
|
104
|
+1. Load the project `SimpleSniffer` into `QtCreator`. There are two ways to do this:
|
107
|
105
|
|
108
|
|
- * Using the virtual machine: Double click the file `SimpleSniffer.pro` located in the folder `/home/eip/labs/classes-simplesniffer` of your virtual machine.
|
109
|
|
- * Downloading the project’s folder from `Bitbucket`: Use a terminal and write the command `git clone http:/bitbucket.org/eip-uprrp/classes-simplesniffer` to download the folder `classes-simplesniffer` from `Bitbucket`. Double click the file `SimpleSniffer.pro` located in the folder that you downloaded to your computer.
|
|
106
|
+ * Using the virtual machine, you need to run QtCreator with administrator (root) privileges.:
|
|
107
|
+`sudo qtcreator /home/eip/labs/classes-simplesniffer/SimpleSniffer.pro`
|
|
108
|
+ * Downloading the project’s folder from `Bitbucket`: Use a terminal and write the command `git clone http:/bitbucket.org/eip-uprrp/classes-simplesniffer` to download the folder `classes-simplesniffer` from `Bitbucket`. In this directory, you need to run QtCreator with administrator (root) privileges:
|
|
109
|
+`sudo qtcreator ./SimpleSniffer.pro`
|
110
|
110
|
|
111
|
|
-3. Configure the project. In this laboratory experience you will be working with the files `ethernet_hdr.h`, `ethernet_packet.h`, `ethernet_packet.cpp`, `ip_packet.h` and `ip_packet.cpp`.
|
|
111
|
+2. Configure the project. In this laboratory experience you will be working with the files `ethernet_hdr.h`, `ethernet_packet.h`, `ethernet_packet.cpp`, `ip_packet.h` and `ip_packet.cpp`.
|
112
|
112
|
|
113
|
113
|
|
114
|
114
|
### Exercise 2 - Complete the class ethernet_packet
|
115
|
115
|
|
116
|
116
|
1. Study the file `ethernet_hdr.h`. This file contains the definition of the data structure that represents an Ethernet header.:
|
117
|
117
|
|
118
|
|
- #define ETHER_ADDR_LEN 6
|
119
|
|
-
|
120
|
|
- struct sniff_ethernet {
|
|
118
|
+ #define ETHER_ADDR_LEN 6
|
|
119
|
+
|
|
120
|
+ struct sniff_ethernet {
|
121
|
121
|
u_char ether_dhost[ETHER_ADDR_LEN]; /* destination host address */
|
122
|
122
|
u_char ether_shost[ETHER_ADDR_LEN]; /* source host address */
|
123
|
123
|
u_short ether_type; /* IP? ARP? RARP? etc */
|
124
|
|
- };
|
125
|
|
-
|
|
124
|
+ };
|
126
|
125
|
|
127
|
|
- The Ethernet header above is used to decode the ethernet part of the raw data in each packet. It is composed of the source MAC address (ether_shost, 6 bytes), the destiantion MAC address (ether_dhost, 6 bytes), and the type of Ethernet packet (ether_type, 2 bytes), which is used to determine if the packet is an IP packet.
|
|
126
|
+ The Ethernet header above is used to decode the ethernet part of the raw data in each packet. It is composed of the source MAC address (ether_shost, 6 bytes), the destiantion MAC address (ether_dhost, 6 bytes), and the type of Ethernet packet (ether_type, 2 bytes), which is used to determine if the packet is an IP packet.
|
128
|
127
|
|
129
|
|
- As you know, it is not a good idea to show this information format to a regular user. Your first task is to define the functions of the C++ class that defines the functions that translate the MAC address information into human readable strings.
|
|
128
|
+ As you know, it is not a good idea to show this information format to a regular user. Your first task is to define the functions of the C++ class that defines the functions that translate the MAC address information into human readable strings.
|
130
|
129
|
|
131
|
130
|
2. The following code is the definition of the class `ethernet_packet`, that can be found in file `ethernet_packet.h`:
|
132
|
131
|
|