Kismet Wireless

Kismet Forums

 

Posted by:nrz
Subject:Insane average values in netxml-file
Date:11:09:16 25/05/2014

> > Hi there.
> > Most of the avrage lon and lats ends up like in antarctica. I have be carrying the device
> >
> > Network 1: BSSID x
> > Manuf : Unknown
> > First : Thu May 22 20:09:49 2014
> > Last : Thu May 22 20:13:10 2014
> > Type : infrastructure
> > BSSID : x
> > SSID 1
> > Type : Beacon
> > SSID : x
> > First : Thu May 22 20:09:49 2014
> > Last : Thu May 22 20:13:10 2014
> > Max Rate : 54.0
> > Beacon : 10
> > Packets : 79
> > Encryption : WPA+PSK
> > Encryption : WPA+AES-CCM
> > Channel : 1
> > Frequency : 2412 - 74 packets, 93.67%
> > Frequency : 2417 - 5 packets, 6.33%
> > Max Seen : 1000
> > LLC : 79
> > Data : 0
> > Crypt : 0
> > Fragments : 0
> > Retries : 0
> > Total : 79
> > Datasize : 0
> > Min Pos : Lat 63.x Lon 20.x Alt 58.200001 Spd 0.566000
> > Max Pos : Lat 63.x Lon 20.x Alt 80.300003 Spd 1.698000
> > Peak Pos : Lat 63.x Lon 20.x Alt 73.699997
> > Avg Pos : AvgLat -175.320580 AvgLon -175.395382 AvgAlt -179337.582100
> > Last BSSTS : x
> > Seen By : wlan1 (wlan1) x 79 packets
> >
> > Kismet is built from Kismet-2013-03-R1b. source on a Rasberry Pi Debian Weezy.
> >
> > Looks like some kind of overflow problem. A few average values are correct mayby there is some kind of correlation to less observation points. No analysis of that has been done.
>
> Confirmed correlation with number of observed data points:
> Frequency : 2432 - 1 packets, 100.00%
> Max Seen : 5000
> LLC : 0
> Data : 1
> Crypt : 0
> Fragments : 0
> Retries : 0
> Total : 1
> Datasize : 24
> Min Pos : Lat 63.x Lon 20.x Alt 59.000000 Spd 0.926000
> Max Pos : Lat 63.x Lon 20.x Alt 59.000000 Spd 0.926000
> Peak Pos : Lat 63.x Lon 20.x Alt 59.000000
> Avg Pos : AvgLat 63.x AvgLon 20.x AvgAlt 59.000000

This patch fixes the problem by using a bigger integer type. Verified on a raspberry pi but the problem should be present on all plattforms where 32-bit integers actually are 32-bit. The comments regarding number range is not corrected.

diff -Naur orig/gpscore.h new/gpscore.h
--- orig/gpscore.h 2013-03-27 15:41:48.000000000 +0100
+++ new/gpscore.h 2014-05-25 12:55:15.000000000 +0200
@@ -183,7 +183,7 @@
double min_lat, min_lon, min_alt, min_spd;
double max_lat, max_lon, max_alt, max_spd;
// Aggregate/avg center position
- long unsigned int add_lat, add_lon, add_alt;
+ uint64_t add_lat, add_lon, add_alt;
double aggregate_lat, aggregate_lon, aggregate_alt;
long aggregate_points;
};
diff -Naur orig/util.cc new/util.cc
--- orig/util.cc 2013-03-27 15:41:48.000000000 +0100
+++ new/util.cc 2014-05-25 12:54:54.000000000 +0200
@@ -1093,11 +1093,11 @@
/* Airware PPI gps conversion code from Johnny Csh */

/*
- * input: a unsigned 32-bit (native endian) value between 0 and 3600000000 (inclusive)
+ * input: a unsigned 64-bit (native endian) value between 0 and 3600000000 (inclusive)
* output: a signed floating point value betwen -180.0000000 and + 180.0000000, inclusive)
*/
-double fixed3_7_to_double(u_int32_t in) {
- int32_t remapped_in = in - (180 * 10000000);
+double fixed3_7_to_double(u_int64_t in) {
+ int64_t remapped_in = in - (180 * 10000000);
double ret = (double) ((double) remapped_in / 10000000);
return ret;
}
@@ -1105,16 +1105,16 @@
* input: a native 32 bit unsigned value between 0 and 999999999
* output: a positive floating point value between 000.0000000 and 999.9999999
*/
-double fixed3_6_to_double(u_int32_t in) {
+double fixed3_6_to_double(u_int64_t in) {
double ret = (double) in / 1000000.0;
return ret;
}
/*
- * input: a native 32 bit unsigned value between 0 and 999.999999
+ * input: a native 64 bit unsigned value between 0 and 999.999999
* output: a signed floating point value between -180000.0000 and +180000.0000
*/
-double fixed6_4_to_double(u_int32_t in) {
- int32_t remapped_in = in - (180000 * 10000);
+double fixed6_4_to_double(u_int64_t in) {
+ int64_t remapped_in = in - (180000 * 10000);
double ret = (double) ((double) remapped_in / 10000);
return ret;
}
@@ -1130,38 +1130,38 @@

/*
* input: a signed floating point value betwen -180.0000000 and + 180.0000000, inclusive)
- * output: a unsigned 32-bit (native endian) value between 0 and 3600000000 (inclusive)
+ * output: a unsigned 64-bit (native endian) value between 0 and 3600000000 (inclusive)
*/
-u_int32_t double_to_fixed3_7(double in)
+u_int64_t double_to_fixed3_7(double in)
{
- if (in < -180 || in >= 180)
+ if (in < -180 || in >= 180)
return 0;
//This may be positive or negative.
- int32_t scaled_in = (int32_t) ((in) * (double) 10000000);
+ int64_t scaled_in = (int64_t) ((in) * (double) 10000000);
//If the input conditions are met, this will now always be positive.
- u_int32_t ret = (u_int32_t) (scaled_in + ((int32_t) 180 * 10000000));
+ u_int64_t ret = (u_int64_t) (scaled_in + ((int64_t) 180 * 10000000));
return ret;
}
/*
* input: a signed floating point value betwen -180000.0000 and + 180000.0000, inclusive)
- * output: a unsigned 32-bit (native endian) value between 0 and 3600000000 (inclusive)
+ * output: a unsigned 64-bit (native endian) value between 0 and 3600000000 (inclusive)
*/
-u_int32_t double_to_fixed6_4(double in)
+u_int64_t double_to_fixed6_4(double in)
{
- if (in < -180000.0001 || in >= 180000.0001)
+ if (in < -180000.0001 || in >= 180000.0001)
return 0;
//This may be positive or negative.
- int32_t scaled_in = (int32_t) ((in) * (double) 10000);
+ int64_t scaled_in = (int64_t) ((in) * (double) 10000);
//If the input conditions are met, this will now always be positive.
- u_int32_t ret = (u_int32_t) (scaled_in + ((int32_t) 180000 * 10000));
+ u_int64_t ret = (u_int64_t) (scaled_in + ((int64_t) 180000 * 10000));
return ret;
}
/*
* input: a positive floating point value between 000.0000000 and 999.9999999
* output: a native 32 bit unsigned value between 0 and 999999999
*/
-u_int32_t double_to_fixed3_6(double in) {
- u_int32_t ret = (u_int32_t) (in * (double) 1000000.0);
+u_int64_t double_to_fixed3_6(double in) {
+ u_int64_t ret = (u_int64_t) (in * (double) 1000000.0);
return ret;
}

diff -Naur orig/util.h new/util.h
--- orig/util.h 2013-03-27 15:41:48.000000000 +0100
+++ new/util.h 2014-05-25 12:54:54.000000000 +0200
@@ -236,13 +236,13 @@
* the fixedX_Y fixed point values into 'native' doubles for displaying.
* Documentation on these formats can be found in the PPI-GEOLOCATION specification
*/
-double fixed3_7_to_double(u_int32_t in);
-double fixed3_6_to_double(u_int32_t in);
-double fixed6_4_to_double(u_int32_t in);
+double fixed3_7_to_double(u_int64_t in);
+double fixed3_6_to_double(u_int64_t in);
+double fixed6_4_to_double(u_int64_t in);

-u_int32_t double_to_fixed3_7(double in);
-u_int32_t double_to_fixed3_6(double in);
-u_int32_t double_to_fixed6_4(double in);
+u_int64_t double_to_fixed3_7(double in);
+u_int64_t double_to_fixed3_6(double in);
+u_int64_t double_to_fixed6_4(double in);

/*
* Some values are encoded as 32-bit unsigned nano-second counters.


Reply to this message