Set expedite TOS for client stream as well
This commit is contained in:
+27
-6
@@ -24,6 +24,7 @@
|
|||||||
#include <ifaddrs.h>
|
#include <ifaddrs.h>
|
||||||
#include <linux/ipv6.h>
|
#include <linux/ipv6.h>
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
|
#include <netinet/ip.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
@@ -31,6 +32,11 @@
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#ifndef IPTOS_DSCP_EF
|
||||||
|
// constant is not defined in Android ip.h
|
||||||
|
#define IPTOS_DSCP_EF 0xb8
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
void wivrn_session::handshake()
|
void wivrn_session::handshake()
|
||||||
@@ -66,6 +72,25 @@ void wivrn_session::handshake()
|
|||||||
throw std::runtime_error("No handshake received");
|
throw std::runtime_error("No handshake received");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
template <typename T>
|
||||||
|
void init_stream(T & stream)
|
||||||
|
{
|
||||||
|
stream.set_receive_buffer_size(1024 * 1024 * 5);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
stream.set_tos(IPTOS_DSCP_EF);
|
||||||
|
}
|
||||||
|
catch (std::exception & e)
|
||||||
|
{
|
||||||
|
spdlog::warn("Failed to set IP ToS to Expedited Forwarding: {}", e.what());
|
||||||
|
}
|
||||||
|
// If this packet is lost, a tracking packet will do the job to establish the connection
|
||||||
|
stream.send(from_headset::handshake{});
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
wivrn_session::wivrn_session(in6_addr address, int port) :
|
wivrn_session::wivrn_session(in6_addr address, int port) :
|
||||||
control(address, port), stream(), address(address)
|
control(address, port), stream(), address(address)
|
||||||
{
|
{
|
||||||
@@ -73,9 +98,7 @@ wivrn_session::wivrn_session(in6_addr address, int port) :
|
|||||||
spdlog::info("Connection to {}:{}", inet_ntop(AF_INET6, &address, buffer, sizeof(buffer)), port);
|
spdlog::info("Connection to {}:{}", inet_ntop(AF_INET6, &address, buffer, sizeof(buffer)), port);
|
||||||
handshake();
|
handshake();
|
||||||
stream.connect(address, port);
|
stream.connect(address, port);
|
||||||
stream.set_receive_buffer_size(1024 * 1024 * 5);
|
init_stream(stream);
|
||||||
// If this packet is lost, a tracking packet will do the job to establish the connection
|
|
||||||
send_stream(from_headset::handshake{});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wivrn_session::wivrn_session(in_addr address, int port) :
|
wivrn_session::wivrn_session(in_addr address, int port) :
|
||||||
@@ -85,7 +108,5 @@ wivrn_session::wivrn_session(in_addr address, int port) :
|
|||||||
spdlog::info("Connection to {}:{}", inet_ntop(AF_INET, &address, buffer, sizeof(buffer)), port);
|
spdlog::info("Connection to {}:{}", inet_ntop(AF_INET, &address, buffer, sizeof(buffer)), port);
|
||||||
handshake();
|
handshake();
|
||||||
stream.connect(address, port);
|
stream.connect(address, port);
|
||||||
stream.set_receive_buffer_size(1024 * 1024 * 5);
|
init_stream(stream);
|
||||||
// If this packet is lost, a tracking packet will do the job to establish the connection
|
|
||||||
send_stream(from_headset::handshake{});
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user