Skip to content

STA Statistics measured by the Agents and sent to the Controller

Jose Saldana edited this page Jun 5, 2017 · 4 revisions

A set of statistics about each connected STA are gathered by each of the agents and forwarded to the controller.

You can see them if you run the Controller application ShowStatistics.java

The code of the agent was added in these commits

Code for updating the statistics

The code is mainly included in these functions, which are updated every time a packet is sent/received by the Agent:

  void OdinAgent::update_rx_stats(Packet *p)
  void OdinAgent::update_tx_stats(Packet *p)

Note: 'sent' means 'downlink' and 'received' means 'uplink', as we are talking about the Agent (i.e. the AP).

Code for sending the statistics to the controller

When the controller requests the tx/rx statistics of all the STAs associated to this AP, it sends a request to the agent.

In the agent, the function String OdinAgent::read_handler(Element *e, void *user_data) includes two handlers for transmission of tx/rx statistics, namely case handler_txstat and case handler_rxstat.

Initial and final timestamps

All the statistics are collected during an interval between init time and end time, both in seconds

Both timestamps are calculated this way in the agent:

  stat._time_first_packet.assign_now();
  (...)
  stat._time_last_packet.assign_now();

Both timestamps are obtained this way in the controller:

  init time: " + vals_entry_rx.getValue().get("first_received") + " sec"
  end time: " + vals_entry_rx.getValue().get("last_received") + " sec"
  (...)
  init time: " + vals_entry_tx.getValue().get("first_received") + " sec"
  end time: " + vals_entry_tx.getValue().get("last_received") + " sec"

Number of packets received/sent during the interval

It is calculated this way in the agent:

  stat._packets++;

It is obtained this way in the controller:

  num packets: " + vals_entry_rx.getValue().get("packets")
  (...)
  num packets: " + vals_entry_tx.getValue().get("packets")     

Average rate of the packets received/sent during the interval

It is calculated this way in the agent:

  stat._avg_rate = stat._avg_rate + ((stat._rate*500 - stat._avg_rate)/stat._packets); // rate in Kbps

It is obtained this way in the controller:

  avg rate: " + vals_entry_rx.getValue().get("avg_rate") + " kbps"
  (...)
  avg rate: " + vals_entry_tx.getValue().get("avg_rate") + " kbps"

Average signal level of the packets received/sent during the interval

It is calculated this way in the agent:

  // Calculate the value of the signal, converting from dBm to mW and back
  double signal_mW;
  double avg_signal_mW;
  signal_mW = pow (10, (stat._signal - 256) / 10);
  if (first_packet)	// if this is the first packet, the previous average will be 0
        avg_signal_mW  = 0;
  else 
        avg_signal_mW  = pow (10, stat._avg_signal / 10);
        avg_signal_mW = avg_signal_mW + ((signal_mW - avg_signal_mW)/stat._packets);
        stat._avg_signal = 10 * log10 (avg_signal_mW); // signal in dBm

It is obtained this way in the controller:

  avg signal: " + vals_entry_rx.getValue().get("avg_signal") + " dBm"
  (...)
  avg signal: " + vals_entry_tx.getValue().get("avg_signal") + " dBm"

Average length (at IP level) of the packets received/sent during the interval

It is calculated this way in the agent:

  stat._avg_len_pkt = stat._avg_len_pkt + ((stat._len_pkt - stat._avg_len_pkt)/stat._packets); // length in bytes
  (...)

It is obtained this way in the controller:

  avg length: " + vals_entry_rx.getValue().get("avg_len_pkt") + " bytes"
  (...)
  avg length: " + vals_entry_tx.getValue().get("avg_len_pkt") + " bytes"

Air time consumed by these packets received/sent during the interval

It gives an idea of the air time this packet has consumed, i.e. the length in bits / the rate.

It is calculated this way in the agent. It is accummulated for each of the packets:

  stat._air_time = stat._air_time + ((double)(8*stat._len_pkt) / (double)(stat._rate*500)); // time used by this packet (in ms)
  (...)

It is obtained this way in the controller:

  air time: " + vals_entry_rx.getValue().get("air_time") + " ms"				
  (...)
  air time: " + vals_entry_tx.getValue().get("air_time") + " ms"
Clone this wiki locally