Skip to content

Commit

Permalink
Add distributed mode for control plane
Browse files Browse the repository at this point in the history
  • Loading branch information
svpcom committed Sep 13, 2024
1 parent 557eef0 commit a41cd37
Show file tree
Hide file tree
Showing 17 changed files with 2,139 additions and 1,107 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ _CFLAGS := $(CFLAGS) -Wall -O2 -fno-strict-aliasing -DWFB_VERSION='"$(VERSION)-$
all: all_bin gs.key test

$(ENV):
virtualenv --python=$(PYTHON) $(ENV)
$(PYTHON) -m virtualenv $(ENV)
$$(PATH=$(ENV)/bin:$(ENV)/local/bin:$(PATH) which pip3) install --upgrade pip setuptools $(STDEB)

all_bin: wfb_rx wfb_tx wfb_keygen wfb_tx_cmd
Expand Down
2 changes: 1 addition & 1 deletion scripts/install_gs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ apt update
apt upgrade

apt install python3-all python3-all-dev libpcap-dev libsodium-dev python3-pip python3-pyroute2 python3-msgpack \
python3-future python3-twisted python3-serial iw virtualenv debhelper dh-python fakeroot build-essential -y
python3-future python3-twisted python3-serial python3-jinja2 iw virtualenv debhelper dh-python fakeroot build-essential -y

# Build
make deb
Expand Down
2 changes: 1 addition & 1 deletion scripts/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Type=simple
EnvironmentFile=/etc/default/wifibroadcast
# per-profile environment
EnvironmentFile=-/etc/default/wifibroadcast.%i
ExecStart=/usr/bin/wfb-server %i ${WFB_NICS}
ExecStart=/bin/bash -c "exec /usr/bin/wfb-server --profiles $(echo %i | tr : ' ') --wlans ${WFB_NICS}"
TimeoutStopSec=5s
Restart=on-failure
RestartSec=5s
Expand Down
18 changes: 9 additions & 9 deletions src/rx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ extern "C"
using namespace std;


Receiver::Receiver(const char *wlan, int wlan_idx, uint32_t channel_id, BaseAggregator *agg) : wlan_idx(wlan_idx), agg(agg)
Receiver::Receiver(const char *wlan, int wlan_idx, uint32_t channel_id, BaseAggregator *agg, int rcv_buf_size) : wlan_idx(wlan_idx), agg(agg)
{
char errbuf[PCAP_ERRBUF_SIZE];

Expand All @@ -60,9 +60,10 @@ Receiver::Receiver(const char *wlan, int wlan_idx, uint32_t channel_id, BaseAggr
throw runtime_error(string_format("Unable to open interface %s in pcap: %s", wlan, errbuf));
}

if (pcap_set_snaplen(ppcap, 4096) !=0) throw runtime_error("set_snaplen failed");
if (rcv_buf_size > 0 && pcap_set_buffer_size(ppcap, rcv_buf_size) != 0) throw runtime_error("set_buffer_size failed");
if (pcap_set_snaplen(ppcap, MAX_PCAP_PACKET_SIZE) != 0) throw runtime_error("set_snaplen failed");
if (pcap_set_promisc(ppcap, 1) != 0) throw runtime_error("set_promisc failed");
if (pcap_set_timeout(ppcap, -1) !=0) throw runtime_error("set_timeout failed");
if (pcap_set_timeout(ppcap, -1) != 0) throw runtime_error("set_timeout failed");
if (pcap_set_immediate_mode(ppcap, 1) != 0) throw runtime_error(string_format("pcap_set_immediate_mode failed: %s", pcap_geterr(ppcap)));
if (pcap_activate(ppcap) !=0) throw runtime_error(string_format("pcap_activate failed: %s", pcap_geterr(ppcap)));
if (pcap_setnonblock(ppcap, 1, errbuf) != 0) throw runtime_error(string_format("set_nonblock failed: %s", errbuf));
Expand Down Expand Up @@ -850,7 +851,7 @@ void Aggregator::apply_fec(int ring_idx)
fec_decode(fec_p, (const uint8_t**)in_blocks, out_blocks, index, MAX_FEC_PAYLOAD);
}

void radio_loop(int argc, char* const *argv, int optind, uint32_t channel_id, shared_ptr<BaseAggregator> agg, int log_interval)
void radio_loop(int argc, char* const *argv, int optind, uint32_t channel_id, shared_ptr<BaseAggregator> agg, int log_interval, int rcv_buf_size)
{
int nfds = argc - optind;
uint64_t log_send_ts = 0;
Expand All @@ -866,7 +867,7 @@ void radio_loop(int argc, char* const *argv, int optind, uint32_t channel_id, sh

for(int i = 0; i < nfds; i++)
{
rx[i] = new Receiver(argv[optind + i], i, channel_id, agg.get());
rx[i] = new Receiver(argv[optind + i], i, channel_id, agg.get(), rcv_buf_size);
fds[i].fd = rx[i]->getfd();
fds[i].events = POLLIN;
}
Expand Down Expand Up @@ -970,7 +971,6 @@ void network_loop(int srv_port, Aggregator &agg, int log_interval, int rcv_buf_s

if (rsize < (ssize_t)sizeof(wrxfwd_t))
{
fprintf(stderr, "Short packet (rx fwd header)\n");
continue;
}
agg.process_packet(buf, rsize - sizeof(wrxfwd_t),
Expand Down Expand Up @@ -1035,8 +1035,8 @@ int main(int argc, char* const *argv)
break;
default: /* '?' */
show_usage:
fprintf(stderr, "Local receiver: %s [-K rx_key] [-c client_addr] [-u client_port] [-p radio_port] [-l log_interval] [-e epoch] [-i link_id] interface1 [interface2] ...\n", argv[0]);
fprintf(stderr, "Remote (forwarder): %s -f [-c client_addr] [-u client_port] [-p radio_port] [-i link_id] interface1 [interface2] ...\n", argv[0]);
fprintf(stderr, "Local receiver: %s [-K rx_key] [-c client_addr] [-u client_port] [-p radio_port] [-R rcv_buf] [-l log_interval] [-e epoch] [-i link_id] interface1 [interface2] ...\n", argv[0]);
fprintf(stderr, "Remote (forwarder): %s -f [-c client_addr] [-u client_port] [-p radio_port] [-R rcv_buf] [-i link_id] interface1 [interface2] ...\n", argv[0]);
fprintf(stderr, "Remote (aggregator): %s -a server_port [-K rx_key] [-c client_addr] [-R rcv_buf] [-u client_port] [-l log_interval] [-p radio_port] [-e epoch] [-i link_id]\n", argv[0]);
fprintf(stderr, "Default: K='%s', connect=%s:%d, link_id=0x%06x, radio_port=%u, epoch=%" PRIu64 ", log_interval=%d, rcv_buf=system_default\n", keypair.c_str(), client_addr.c_str(), client_port, link_id, radio_port, epoch, log_interval);
fprintf(stderr, "WFB-ng version %s\n", WFB_VERSION);
Expand Down Expand Up @@ -1080,7 +1080,7 @@ int main(int argc, char* const *argv)
agg = shared_ptr<Forwarder>(new Forwarder(client_addr, client_port));
}

radio_loop(argc, argv, optind, channel_id, agg, log_interval);
radio_loop(argc, argv, optind, channel_id, agg, log_interval, rcv_buf);
}else if(rx_mode == AGGREGATOR)
{
if (optind > argc) goto show_usage;
Expand Down
2 changes: 1 addition & 1 deletion src/rx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class Aggregator : public BaseAggregator
class Receiver
{
public:
Receiver(const char* wlan, int wlan_idx, uint32_t channel_id, BaseAggregator* agg);
Receiver(const char* wlan, int wlan_idx, uint32_t channel_id, BaseAggregator* agg, int rcv_buf_size);
~Receiver();
void loop_iter(void);
int getfd(void){ return fd; }
Expand Down
Loading

0 comments on commit a41cd37

Please sign in to comment.