mirror of
https://github.com/svpcom/wfb-ng.git
synced 2025-02-19 07:03:48 -04:00
Fix type of rssi variable.
Fix issue with multiple antenna stats in one packet.
This commit is contained in:
parent
babd777cef
commit
778ae91c4c
16
rx.cpp
16
rx.cpp
@ -1,6 +1,6 @@
|
|||||||
// -*- C++ -*-
|
// -*- C++ -*-
|
||||||
//
|
//
|
||||||
// Copyright (C) 2017 Vasily Evseenko <svpcom@p2ptech.org>
|
// Copyright (C) 2017, 2018 Vasily Evseenko <svpcom@p2ptech.org>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -31,6 +31,7 @@
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
@ -117,7 +118,7 @@ void Receiver::loop_iter(void)
|
|||||||
int pktlen = hdr.caplen;
|
int pktlen = hdr.caplen;
|
||||||
// int pkt_rate = 0
|
// int pkt_rate = 0
|
||||||
uint8_t antenna = 0;
|
uint8_t antenna = 0;
|
||||||
uint8_t rssi = 0;
|
int8_t rssi = SCHAR_MIN;
|
||||||
uint8_t flags = 0;
|
uint8_t flags = 0;
|
||||||
struct ieee80211_radiotap_iterator iterator;
|
struct ieee80211_radiotap_iterator iterator;
|
||||||
int ret = ieee80211_radiotap_iterator_init(&iterator, (ieee80211_radiotap_header*)pkt, pktlen, NULL);
|
int ret = ieee80211_radiotap_iterator_init(&iterator, (ieee80211_radiotap_header*)pkt, pktlen, NULL);
|
||||||
@ -147,11 +148,14 @@ void Receiver::loop_iter(void)
|
|||||||
// break;
|
// break;
|
||||||
|
|
||||||
case IEEE80211_RADIOTAP_ANTENNA:
|
case IEEE80211_RADIOTAP_ANTENNA:
|
||||||
|
// FIXME
|
||||||
|
// In case of multiple antenna stats in one packet this index will be irrelivant
|
||||||
antenna = *(uint8_t*)(iterator.this_arg);
|
antenna = *(uint8_t*)(iterator.this_arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IEEE80211_RADIOTAP_DBM_ANTSIGNAL:
|
case IEEE80211_RADIOTAP_DBM_ANTSIGNAL:
|
||||||
rssi = *(int8_t*)(iterator.this_arg);
|
// Some cards can provide rssi for multiple antennas in one packet, so we should select maximum value
|
||||||
|
rssi = max(rssi, *(int8_t*)(iterator.this_arg));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IEEE80211_RADIOTAP_FLAGS:
|
case IEEE80211_RADIOTAP_FLAGS:
|
||||||
@ -249,7 +253,7 @@ Forwarder::Forwarder(const string &client_addr, int client_port)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Forwarder::process_packet(const uint8_t *buf, size_t size, uint8_t wlan_idx, uint8_t antenna, uint8_t rssi, sockaddr_in *sockaddr)
|
void Forwarder::process_packet(const uint8_t *buf, size_t size, uint8_t wlan_idx, uint8_t antenna, int8_t rssi, sockaddr_in *sockaddr)
|
||||||
{
|
{
|
||||||
wrxfwd_t fwd_hdr = { .wlan_idx = wlan_idx,
|
wrxfwd_t fwd_hdr = { .wlan_idx = wlan_idx,
|
||||||
.antenna = antenna,
|
.antenna = antenna,
|
||||||
@ -358,7 +362,7 @@ void Aggregator::dump_stats(FILE *fp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Aggregator::log_rssi(const sockaddr_in *sockaddr, uint8_t wlan_idx, uint8_t ant, uint8_t rssi)
|
void Aggregator::log_rssi(const sockaddr_in *sockaddr, uint8_t wlan_idx, uint8_t ant, int8_t rssi)
|
||||||
{
|
{
|
||||||
// key: addr + port + wlan_idx + ant
|
// key: addr + port + wlan_idx + ant
|
||||||
uint64_t key = 0;
|
uint64_t key = 0;
|
||||||
@ -373,7 +377,7 @@ void Aggregator::log_rssi(const sockaddr_in *sockaddr, uint8_t wlan_idx, uint8_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Aggregator::process_packet(const uint8_t *buf, size_t size, uint8_t wlan_idx, uint8_t antenna, uint8_t rssi, sockaddr_in *sockaddr)
|
void Aggregator::process_packet(const uint8_t *buf, size_t size, uint8_t wlan_idx, uint8_t antenna, int8_t rssi, sockaddr_in *sockaddr)
|
||||||
{
|
{
|
||||||
uint8_t new_session_key[sizeof(session_key)];
|
uint8_t new_session_key[sizeof(session_key)];
|
||||||
count_p_all += 1;
|
count_p_all += 1;
|
||||||
|
20
rx.hpp
20
rx.hpp
@ -1,6 +1,6 @@
|
|||||||
// -*- C++ -*-
|
// -*- C++ -*-
|
||||||
//
|
//
|
||||||
// Copyright (C) 2017 Vasily Evseenko <svpcom@p2ptech.org>
|
// Copyright (C) 2017, 2018 Vasily Evseenko <svpcom@p2ptech.org>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -28,7 +28,7 @@ typedef enum {
|
|||||||
class BaseAggregator
|
class BaseAggregator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void process_packet(const uint8_t *buf, size_t size, uint8_t wlan_idx, uint8_t antenna, uint8_t rssi, sockaddr_in *sockaddr) = 0;
|
virtual void process_packet(const uint8_t *buf, size_t size, uint8_t wlan_idx, uint8_t antenna, int8_t rssi, sockaddr_in *sockaddr) = 0;
|
||||||
virtual void dump_stats(FILE *fp) = 0;
|
virtual void dump_stats(FILE *fp) = 0;
|
||||||
protected:
|
protected:
|
||||||
int open_udp_socket_for_tx(const string &client_addr, int client_port)
|
int open_udp_socket_for_tx(const string &client_addr, int client_port)
|
||||||
@ -56,7 +56,7 @@ class Forwarder : public BaseAggregator
|
|||||||
public:
|
public:
|
||||||
Forwarder(const string &client_addr, int client_port);
|
Forwarder(const string &client_addr, int client_port);
|
||||||
~Forwarder();
|
~Forwarder();
|
||||||
virtual void process_packet(const uint8_t *buf, size_t size, uint8_t wlan_idx, uint8_t antenna, uint8_t rssi, sockaddr_in *sockaddr);
|
virtual void process_packet(const uint8_t *buf, size_t size, uint8_t wlan_idx, uint8_t antenna, int8_t rssi, sockaddr_in *sockaddr);
|
||||||
virtual void dump_stats(FILE *fp) {}
|
virtual void dump_stats(FILE *fp) {}
|
||||||
private:
|
private:
|
||||||
int sockfd;
|
int sockfd;
|
||||||
@ -84,7 +84,7 @@ class antennaItem
|
|||||||
public:
|
public:
|
||||||
antennaItem(void) : count_all(0), rssi_sum(0), rssi_min(0), rssi_max(0) {}
|
antennaItem(void) : count_all(0), rssi_sum(0), rssi_min(0), rssi_max(0) {}
|
||||||
|
|
||||||
void log_rssi(uint8_t rssi){
|
void log_rssi(int8_t rssi){
|
||||||
if(count_all == 0){
|
if(count_all == 0){
|
||||||
rssi_min = rssi;
|
rssi_min = rssi;
|
||||||
rssi_max = rssi;
|
rssi_max = rssi;
|
||||||
@ -96,10 +96,10 @@ public:
|
|||||||
count_all += 1;
|
count_all += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t count_all;
|
int32_t count_all;
|
||||||
uint32_t rssi_sum;
|
int32_t rssi_sum;
|
||||||
uint8_t rssi_min;
|
int8_t rssi_min;
|
||||||
uint8_t rssi_max;
|
int8_t rssi_max;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::unordered_map<uint64_t, antennaItem> antenna_stat_t;
|
typedef std::unordered_map<uint64_t, antennaItem> antenna_stat_t;
|
||||||
@ -109,12 +109,12 @@ class Aggregator : public BaseAggregator
|
|||||||
public:
|
public:
|
||||||
Aggregator(const string &client_addr, int client_port, int k, int n, const string &keypair);
|
Aggregator(const string &client_addr, int client_port, int k, int n, const string &keypair);
|
||||||
~Aggregator();
|
~Aggregator();
|
||||||
virtual void process_packet(const uint8_t *buf, size_t size, uint8_t wlan_idx, uint8_t antenna, uint8_t rssi, sockaddr_in *sockaddr);
|
virtual void process_packet(const uint8_t *buf, size_t size, uint8_t wlan_idx, uint8_t antenna, int8_t rssi, sockaddr_in *sockaddr);
|
||||||
virtual void dump_stats(FILE *fp);
|
virtual void dump_stats(FILE *fp);
|
||||||
private:
|
private:
|
||||||
void send_packet(int ring_idx, int fragment_idx);
|
void send_packet(int ring_idx, int fragment_idx);
|
||||||
void apply_fec(int ring_idx);
|
void apply_fec(int ring_idx);
|
||||||
void log_rssi(const sockaddr_in *sockaddr, uint8_t wlan_idx, uint8_t ant, uint8_t rssi);
|
void log_rssi(const sockaddr_in *sockaddr, uint8_t wlan_idx, uint8_t ant, int8_t rssi);
|
||||||
int get_block_ring_idx(uint64_t block_idx);
|
int get_block_ring_idx(uint64_t block_idx);
|
||||||
int rx_ring_push(void);
|
int rx_ring_push(void);
|
||||||
fec_t* fec_p;
|
fec_t* fec_p;
|
||||||
|
4
tx.hpp
4
tx.hpp
@ -1,6 +1,6 @@
|
|||||||
// -*- C++ -*-
|
// -*- C++ -*-
|
||||||
//
|
//
|
||||||
// Copyright (C) 2017 Vasily Evseenko <svpcom@p2ptech.org>
|
// Copyright (C) 2017, 2018 Vasily Evseenko <svpcom@p2ptech.org>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -87,7 +87,7 @@ private:
|
|||||||
{
|
{
|
||||||
wrxfwd_t fwd_hdr = { .wlan_idx = (uint8_t)(rand() % 2),
|
wrxfwd_t fwd_hdr = { .wlan_idx = (uint8_t)(rand() % 2),
|
||||||
.antenna = (uint8_t)(rand() % 2),
|
.antenna = (uint8_t)(rand() % 2),
|
||||||
.rssi = (uint8_t)(rand() & 0xff) };
|
.rssi = (int8_t)(rand() & 0xff) };
|
||||||
|
|
||||||
struct iovec iov[2] = {{ .iov_base = (void*)&fwd_hdr,
|
struct iovec iov[2] = {{ .iov_base = (void*)&fwd_hdr,
|
||||||
.iov_len = sizeof(fwd_hdr)},
|
.iov_len = sizeof(fwd_hdr)},
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2017 Vasily Evseenko <svpcom@p2ptech.org>
|
// Copyright (C) 2017, 2018 Vasily Evseenko <svpcom@p2ptech.org>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -116,7 +116,7 @@ static uint8_t ieee80211_header[] = {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t wlan_idx;
|
uint8_t wlan_idx;
|
||||||
uint8_t antenna; //RADIOTAP_ANTENNA
|
uint8_t antenna; //RADIOTAP_ANTENNA
|
||||||
uint8_t rssi; //RADIOTAP_DBM_ANTSIGNAL
|
int8_t rssi; //RADIOTAP_DBM_ANTSIGNAL
|
||||||
} __attribute__ ((packed)) wrxfwd_t;
|
} __attribute__ ((packed)) wrxfwd_t;
|
||||||
|
|
||||||
// Network packet headers. All numbers are in network (big endian) format
|
// Network packet headers. All numbers are in network (big endian) format
|
||||||
|
Loading…
Reference in New Issue
Block a user