[Aggregator] Handle the packet numbering

This commit is contained in:
Matteo Cypriani 2011-10-25 19:28:49 +02:00
parent 1cc1ce4302
commit 5ab5b4f22f
2 changed files with 24 additions and 5 deletions

View File

@ -35,6 +35,8 @@
/* Linked list storing data of each request */ /* Linked list storing data of each request */
typedef struct _request_info_list typedef struct _request_info_list
{ {
// Number of the current packet:
uint16_t packet_id ;
// MAC address of the transmitter AP (in bytes): // MAC address of the transmitter AP (in bytes):
uint8_t ap_mac_addr_bytes[ETHER_ADDR_LEN] ; uint8_t ap_mac_addr_bytes[ETHER_ADDR_LEN] ;
// Signal strength received by the AP from the mobile: // Signal strength received by the AP from the mobile:
@ -48,6 +50,9 @@ typedef struct _request_list
{ {
uint8_t type ; uint8_t type ;
// Number of packets sent by the mobile for this request:
uint16_t nb_packets ;
/* Request identifier */ /* Request identifier */
// Mobile MAC address (in bytes): // Mobile MAC address (in bytes):
uint8_t mobile_mac_addr_bytes[ETHER_ADDR_LEN] ; uint8_t mobile_mac_addr_bytes[ETHER_ADDR_LEN] ;

View File

@ -501,6 +501,8 @@ int read_loop(int sockfd)
request.x_position = owl_ntohf(request.x_position) ; request.x_position = owl_ntohf(request.x_position) ;
request.y_position = owl_ntohf(request.y_position) ; request.y_position = owl_ntohf(request.y_position) ;
request.z_position = owl_ntohf(request.z_position) ; request.z_position = owl_ntohf(request.z_position) ;
request.packet_id = ntohs(request.packet_id) ;
request.nb_packets = ntohs(request.nb_packets) ;
if (VERBOSE_REQUESTS) if (VERBOSE_REQUESTS)
{ {
@ -529,13 +531,14 @@ int read_loop(int sockfd)
"\tAP MAC: %s\n" "\tAP MAC: %s\n"
"\tMobile MAC: %s\n" "\tMobile MAC: %s\n"
"\tMobile IP: %s\n" "\tMobile IP: %s\n"
"\tSequence number (request timestamp): %s\n" "\tRequest timestamp: %s\n"
"\tRequest arrival time on the AP: %s\n" "\tRequest arrival time on the AP: %s\n"
"\tSignal: %d dBm\n" "\tSignal: %d dBm\n"
"\tPosition X: %f\n" "\tPosition X: %f\n"
"\tPosition Y: %f\n" "\tPosition Y: %f\n"
"\tPosition Z: %f\n" "\tPosition Z: %f\n"
"\tDirection: %"PRIu8"\n" "\tDirection: %"PRIu8"\n"
"\tPacket number: %"PRIu16"/%"PRIu16"\n"
, ,
request.type, request.type,
ap_mac_addr_str, ap_mac_addr_str,
@ -547,7 +550,9 @@ int read_loop(int sockfd)
request.x_position, request.x_position,
request.y_position, request.y_position,
request.z_position, request.z_position,
request.direction request.direction,
request.packet_id,
request.nb_packets
) ; ) ;
} }
else if (VERBOSE_CHATTERBOX) else if (VERBOSE_CHATTERBOX)
@ -643,8 +648,10 @@ void* monitor_requests(void *NULL_value)
mac_str) ; mac_str) ;
fprintf(fd, "%s;", mac_str) ; fprintf(fd, "%s;", mac_str) ;
// Print request type to the output file // Print request type & number of packets to the
fprintf(fd, "%"PRIu8";", request_ptr->type) ; // output file
fprintf(fd, "%"PRIu8";%"PRIu16";",
request_ptr->type, request_ptr->nb_packets) ;
// Print request mobile timestamp to the output file // Print request mobile timestamp to the output file
owl_timestamp_to_string(&request_ptr->request_time, owl_timestamp_to_string(&request_ptr->request_time,
@ -660,6 +667,7 @@ void* monitor_requests(void *NULL_value)
// Initialise owl_request fields: // Initialise owl_request fields:
request.type = request_ptr->type ; request.type = request_ptr->type ;
request.nb_packets = htons(request_ptr->nb_packets) ;
memcpy(request.mobile_mac_addr_bytes, memcpy(request.mobile_mac_addr_bytes,
request_ptr->mobile_mac_addr_bytes, request_ptr->mobile_mac_addr_bytes,
ETHER_ADDR_LEN) ; ETHER_ADDR_LEN) ;
@ -690,6 +698,8 @@ void* monitor_requests(void *NULL_value)
while (request_info_ptr != NULL) while (request_info_ptr != NULL)
{ {
// Send AP info to the localisation server // Send AP info to the localisation server
info.packet_id =
htons(request_info_ptr->packet_id) ;
memcpy(info.ap_mac_addr_bytes, memcpy(info.ap_mac_addr_bytes,
request_info_ptr->ap_mac_addr_bytes, request_info_ptr->ap_mac_addr_bytes,
ETHER_ADDR_LEN) ; ETHER_ADDR_LEN) ;
@ -701,8 +711,9 @@ void* monitor_requests(void *NULL_value)
owl_mac_bytes_to_string_r(request_info_ptr-> owl_mac_bytes_to_string_r(request_info_ptr->
ap_mac_addr_bytes, ap_mac_addr_bytes,
mac_str) ; mac_str) ;
fprintf(fd, ";%s;%d", fprintf(fd, ";%s;%"PRIu16";%d",
mac_str, mac_str,
request_info_ptr->packet_id,
request_info_ptr->ss_dbm - 256) ; request_info_ptr->ss_dbm - 256) ;
// Delete request // Delete request
@ -772,6 +783,7 @@ void got_request(owl_captured_request request)
/* Create a new request */ /* Create a new request */
tmp_info = malloc(sizeof(request_info_list)) ; tmp_info = malloc(sizeof(request_info_list)) ;
tmp_info->packet_id = request.packet_id ;
memcpy(tmp_info->ap_mac_addr_bytes, request.ap_mac_addr_bytes, memcpy(tmp_info->ap_mac_addr_bytes, request.ap_mac_addr_bytes,
ETHER_ADDR_LEN) ; ETHER_ADDR_LEN) ;
tmp_info->ss_dbm = request.ss_dbm ; tmp_info->ss_dbm = request.ss_dbm ;
@ -788,6 +800,7 @@ void got_request(owl_captured_request request)
owl_mac_bytes_to_string(request.ap_mac_addr_bytes)) ; owl_mac_bytes_to_string(request.ap_mac_addr_bytes)) ;
tmp_request = malloc(sizeof(request_list)) ; // create it. tmp_request = malloc(sizeof(request_list)) ; // create it.
tmp_request->type = request.type ; tmp_request->type = request.type ;
tmp_request->nb_packets = request.nb_packets ;
memcpy(tmp_request->mobile_mac_addr_bytes, memcpy(tmp_request->mobile_mac_addr_bytes,
request.mobile_mac_addr_bytes, ETHER_ADDR_LEN) ; request.mobile_mac_addr_bytes, ETHER_ADDR_LEN) ;
// Explicit packet: // Explicit packet:
@ -848,6 +861,7 @@ void got_request(owl_captured_request request)
owl_mac_bytes_to_string(request.ap_mac_addr_bytes)) ; owl_mac_bytes_to_string(request.ap_mac_addr_bytes)) ;
tmp_request = malloc(sizeof(request_list)) ; // create it tmp_request = malloc(sizeof(request_list)) ; // create it
tmp_request->type = request.type ; tmp_request->type = request.type ;
tmp_request->nb_packets = request.nb_packets ;
memcpy(tmp_request->mobile_mac_addr_bytes, memcpy(tmp_request->mobile_mac_addr_bytes,
request.mobile_mac_addr_bytes, ETHER_ADDR_LEN) ; request.mobile_mac_addr_bytes, ETHER_ADDR_LEN) ;
// Explicit packet: // Explicit packet: