Adding time point recording.

This commit is contained in:
stephb9959
2022-03-18 11:49:40 -07:00
parent b77e600ab3
commit f96a9502be
5 changed files with 225 additions and 138 deletions

View File

@@ -19,7 +19,7 @@ namespace OpenWifi {
DI_.states++;
DI_.connected =true;
DeviceTimePoint DTP;
AnalyticsObjects::DeviceTimePoint DTP;
// find radios first to get associations.
try {
@@ -48,7 +48,7 @@ namespace OpenWifi {
uint radio_index = 0;
for (const auto &radio: radios) {
if (radio.contains("channel")) {
RadioTimePoint RTP;
AnalyticsObjects::RadioTimePoint RTP;
RTP.band = radio["channel"] <= 16 ? 2 : 5;
radio_band[radio_index++] = radio["channel"] <= 16 ? 2 : 5;
GetJSON("busy_ms", radio, RTP.busy_ms, (uint64_t) 0);
@@ -86,7 +86,7 @@ namespace OpenWifi {
if(interface.contains("ssids")) {
auto ssids = interface["ssids"];
for (const auto &ssid: ssids) {
SSIDTimePoint SSIDTP;
AnalyticsObjects::SSIDTimePoint SSIDTP;
uint radio_location = 2;
if(ssid.contains("radio")) {
auto radio = ssid["radio"];
@@ -101,7 +101,7 @@ namespace OpenWifi {
GetJSON("bssid",ssid,bssid, std::string{""});
SSIDTP.bssid = Utils::MACToInt(bssid);
GetJSON("mode",ssid,mode, std::string{""} );
SSIDTP.mode = SSID_Mode(mode);
SSIDTP.mode = AnalyticsObjects::SSID_Mode(mode);
GetJSON("ssid",ssid,ssid_name, std::string{""} );
SSIDTP.ssid = SSID_DICT()->Add(ssid_name);
if (ssid.contains("associations") && ssid["associations"].is_array()) {
@@ -117,7 +117,7 @@ namespace OpenWifi {
DI_.associations_6g += associations.size();
}
for(const auto &association:associations) {
UETimePoint TP;
AnalyticsObjects::UETimePoint TP;
std::string association_bssid,station;
GetJSON("bssid",association,association_bssid, std::string{""} );
GetJSON("station",association,station, std::string{} );
@@ -137,7 +137,7 @@ namespace OpenWifi {
if(association.contains("msdu") && association["msdu"].is_array()) {
auto msdus = association["msdu"];
for(const auto &msdu:msdus) {
msdu_entry E;
AnalyticsObjects::msdu_entry E;
GetJSON("rx_msdu",msdu,E.rx_msdu, (uint64_t)0 );
GetJSON("tx_msdu",msdu,E.tx_msdu, (uint64_t)0 );
GetJSON("tx_msdu_failed",msdu,E.tx_msdu_failed, (uint64_t)0 );
@@ -230,5 +230,4 @@ namespace OpenWifi {
std::cout << Utils::IntToSerialNumber(mac_) << ": health failed parsing." << std::endl;
}
}
}

View File

@@ -16,102 +16,6 @@ namespace OpenWifi {
const uint32_t ap_buffer_size = ap_length / interval;
const uint32_t ue_buffer_size = ue_length / interval;
enum wifi_band {
band_2g=0, band_5g=1, band_6g=2
};
struct msdu_entry {
uint64_t rx_msdu=0,
tx_msdu=0,
tx_msdu_failed=0,
tx_msdu_retries=0;
};
struct UETimePoint {
uint64_t association_bssid=0,station=0;
int64_t rssi=0;
uint64_t tx_bytes=0,
rx_bytes=0,
tx_duration=0,
rx_packets=0,
tx_packets=0,
tx_retries=0,
tx_failed=0,
connected=0,
inactive=0;
std::vector<msdu_entry> msdus;
};
enum SSID_MODES {
unknown=0,
ap,
mesh,
sta,
wds_ap,
wds_sta,
wds_repeater
};
inline SSID_MODES SSID_Mode(const std::string &m) {
if(m=="ap")
return ap;
if(m=="sta")
return sta;
if(m=="mesh")
return mesh;
if(m=="wds-ap")
return wds_ap;
if(m=="wds-sta")
return wds_sta;
if(m=="wds-repeater")
return wds_repeater;
return unknown;
}
struct SSIDTimePoint {
uint64_t bssid=0,
mode=0,
ssid=0;
std::vector<UETimePoint> associations;
};
struct APTimePoint {
uint64_t collisions=0,
multicast=0,
rx_bytes=0,
rx_dropped=0,
rx_errors=0,
rx_packets=0,
tx_bytes=0,
tx_dropped=0,
tx_errors=0,
tx_packets=0;
};
struct RadioTimePoint {
uint band=0,
radio_channel=0;
uint64_t active_ms=0,
busy_ms=0,
receive_ms=0,
transmit_ms=0,
tx_power=0,
channel=0;
int64_t temperature=0,
noise=0;
};
struct DeviceTimePoint {
uint64_t timestamp=0;
APTimePoint ap_data;
std::vector<SSIDTimePoint> ssid_data;
std::vector<RadioTimePoint> radio_data;
AnalyticsObjects::DeviceInfo device_info;
};
class AP {
public:
explicit AP(uint64_t mac) : mac_(mac) {
@@ -126,6 +30,6 @@ namespace OpenWifi {
private:
uint64_t mac_=0;
AnalyticsObjects::DeviceInfo DI_;
std::vector<DeviceTimePoint> DTP_;
std::vector<AnalyticsObjects::DeviceTimePoint> DTP_;
};
}

View File

@@ -129,4 +129,67 @@ namespace OpenWifi::AnalyticsObjects {
return false;
}
void UETimePoint::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"association_bssid",association_bssid);
field_to_json(Obj,"station",station);
field_to_json(Obj,"rssi",rssi);
field_to_json(Obj,"tx_bytes",tx_bytes);
field_to_json(Obj,"rx_bytes",rx_bytes);
field_to_json(Obj,"tx_duration",tx_duration);
field_to_json(Obj,"rx_packets",rx_packets);
field_to_json(Obj,"tx_packets",tx_packets);
field_to_json(Obj,"tx_retries",tx_retries);
field_to_json(Obj,"tx_failed",tx_failed);
field_to_json(Obj,"connected",connected);
field_to_json(Obj,"inactive",inactive);
}
void APTimePoint::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"collisions",collisions);
field_to_json(Obj,"multicast",multicast);
field_to_json(Obj,"rx_bytes",rx_bytes);
field_to_json(Obj,"rx_dropped",rx_dropped);
field_to_json(Obj,"rx_errors",rx_errors);
field_to_json(Obj,"rx_packets",rx_packets);
field_to_json(Obj,"tx_bytes",tx_bytes);
field_to_json(Obj,"tx_packets",tx_packets);
field_to_json(Obj,"tx_dropped",tx_dropped);
field_to_json(Obj,"tx_errors",tx_errors);
field_to_json(Obj,"tx_packets",tx_packets);
}
void msdu_entry::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"rx_msdu",rx_msdu);
field_to_json(Obj,"tx_msdu",tx_msdu);
field_to_json(Obj,"tx_msdu_failed",tx_msdu_failed);
field_to_json(Obj,"tx_msdu_retries",tx_msdu_retries);
}
void RadioTimePoint::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"band",band);
field_to_json(Obj,"radio_channel",radio_channel);
field_to_json(Obj,"active_ms",active_ms);
field_to_json(Obj,"busy_ms",busy_ms);
field_to_json(Obj,"receive_ms",receive_ms);
field_to_json(Obj,"transmit_ms",transmit_ms);
field_to_json(Obj,"tx_power",tx_power);
field_to_json(Obj,"channel",channel);
field_to_json(Obj,"temperature",temperature);
field_to_json(Obj,"noise",noise);
}
void SSIDTimePoint::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"bssid",bssid);
field_to_json(Obj,"mode",mode);
field_to_json(Obj,"ssid",ssid);
field_to_json(Obj,"associations",associations);
}
void DeviceTimePoint::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"timestamp",timestamp);
field_to_json(Obj,"ap_data",ap_data);
field_to_json(Obj,"ssid_data",ssid_data);
field_to_json(Obj,"radio_data",radio_data);
field_to_json(Obj,"device_info",device_info);
}
}

View File

@@ -12,29 +12,32 @@ namespace OpenWifi {
namespace AnalyticsObjects {
struct Report {
uint64_t snapShot=0;
uint64_t snapShot = 0;
void reset();
void to_json(Poco::JSON::Object &Obj) const;
};
struct VenueInfo {
OpenWifi::Types::UUID_t id;
std::string name;
std::string description;
uint64_t retention=0;
uint64_t interval=0;
bool monitorSubVenues=false;
OpenWifi::Types::UUID_t id;
std::string name;
std::string description;
uint64_t retention = 0;
uint64_t interval = 0;
bool monitorSubVenues = false;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct BoardInfo {
ProvObjects::ObjectInfo info;
std::vector<VenueInfo> venueList;
ProvObjects::ObjectInfo info;
std::vector<VenueInfo> venueList;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
inline bool operator<(const BoardInfo &bb) const {
@@ -47,40 +50,149 @@ namespace OpenWifi {
};
struct DeviceInfo {
std::string boardId;
std::string type;
std::string serialNumber;
std::string deviceType;
uint64_t lastContact;
uint64_t lastPing;
uint64_t lastState;
std::string lastFirmware;
uint64_t lastFirmwareUpdate;
uint64_t lastConnection;
uint64_t lastDisconnection;
uint64_t pings;
uint64_t states;
bool connected;
std::string connectionIp;
uint64_t associations_2g;
uint64_t associations_5g;
uint64_t associations_6g;
uint64_t health;
uint64_t lastHealth;
std::string locale;
uint64_t uptime;
double memory;
std::string boardId;
std::string type;
std::string serialNumber;
std::string deviceType;
uint64_t lastContact;
uint64_t lastPing;
uint64_t lastState;
std::string lastFirmware;
uint64_t lastFirmwareUpdate;
uint64_t lastConnection;
uint64_t lastDisconnection;
uint64_t pings;
uint64_t states;
bool connected;
std::string connectionIp;
uint64_t associations_2g;
uint64_t associations_5g;
uint64_t associations_6g;
uint64_t health;
uint64_t lastHealth;
std::string locale;
uint64_t uptime;
double memory;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct DeviceInfoList {
std::vector<DeviceInfo> devices;
std::vector<DeviceInfo> devices;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
}
enum wifi_band {
band_2g = 0, band_5g = 1, band_6g = 2
};
struct msdu_entry {
uint64_t rx_msdu = 0,
tx_msdu = 0,
tx_msdu_failed = 0,
tx_msdu_retries = 0;
void to_json(Poco::JSON::Object &Obj) const;
};
struct UETimePoint {
uint64_t association_bssid = 0,
station = 0;
int64_t rssi = 0;
uint64_t tx_bytes = 0,
rx_bytes = 0,
tx_duration = 0,
rx_packets = 0,
tx_packets = 0,
tx_retries = 0,
tx_failed = 0,
connected = 0,
inactive = 0;
std::vector<msdu_entry> msdus;
void to_json(Poco::JSON::Object &Obj) const;
};
enum SSID_MODES {
unknown = 0,
ap,
mesh,
sta,
wds_ap,
wds_sta,
wds_repeater
};
inline SSID_MODES SSID_Mode(const std::string &m) {
if (m == "ap")
return ap;
if (m == "sta")
return sta;
if (m == "mesh")
return mesh;
if (m == "wds-ap")
return wds_ap;
if (m == "wds-sta")
return wds_sta;
if (m == "wds-repeater")
return wds_repeater;
return unknown;
}
struct SSIDTimePoint {
uint64_t bssid = 0,
mode = 0,
ssid = 0;
std::vector<UETimePoint> associations;
void to_json(Poco::JSON::Object &Obj) const;
};
struct APTimePoint {
uint64_t collisions = 0,
multicast = 0,
rx_bytes = 0,
rx_dropped = 0,
rx_errors = 0,
rx_packets = 0,
tx_bytes = 0,
tx_dropped = 0,
tx_errors = 0,
tx_packets = 0;
void to_json(Poco::JSON::Object &Obj) const;
};
struct RadioTimePoint {
uint band = 0,
radio_channel = 0;
uint64_t active_ms = 0,
busy_ms = 0,
receive_ms = 0,
transmit_ms = 0,
tx_power = 0,
channel = 0;
int64_t temperature = 0,
noise = 0;
void to_json(Poco::JSON::Object &Obj) const;
};
struct DeviceTimePoint {
uint64_t timestamp = 0;
APTimePoint ap_data;
std::vector<SSIDTimePoint> ssid_data;
std::vector<RadioTimePoint> radio_data;
AnalyticsObjects::DeviceInfo device_info;
void to_json(Poco::JSON::Object &Obj) const;
};
}
}

View File

@@ -346,6 +346,15 @@ namespace OpenWifi::RESTAPI_utils {
Obj.set(Field, Value);
}
inline void field_to_json(Poco::JSON::Object &Obj, const char *Field, int64_t Value) {
Obj.set(Field, Value);
}
inline void field_to_json(Poco::JSON::Object &Obj, const char *Field, uint Value) {
Obj.set(Field, Value);
}
template<class T> void field_to_json(Poco::JSON::Object &Obj, const char *Field, const T &Value) {
Poco::JSON::Object Answer;
Value.to_json(Answer);