Add expedited forwarding ToS flag in stream socket

This commit is contained in:
Patrick Nicolas
2023-10-20 11:27:23 +02:00
parent 003f4ed830
commit 3473f00e0c
3 changed files with 20 additions and 0 deletions
+9
View File
@@ -133,6 +133,15 @@ void xrt::drivers::wivrn::UDP::set_receive_buffer_size(int size)
setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size));
}
void xrt::drivers::wivrn::UDP::set_tos(int tos)
{
int err = setsockopt(fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos));
if (err == -1)
{
throw std::system_error{errno, std::generic_category()};
}
}
void xrt::drivers::wivrn::TCP::init()
{
int nodelay = 1;
+1
View File
@@ -96,6 +96,7 @@ public:
void subscribe_multicast(in6_addr address);
void unsubscribe_multicast(in6_addr address);
void set_receive_buffer_size(int size);
void set_tos(int type_of_service);
};
class TCP : public fd_base
+10
View File
@@ -18,6 +18,7 @@
*/
#include "wivrn_connection.h"
#include "util/u_logging.h"
#include <poll.h>
using namespace std::chrono_literals;
@@ -27,6 +28,15 @@ wivrn_connection::wivrn_connection(TCP && tcp, in6_addr address) :
{
stream.bind(stream_server_port);
stream.connect(address, stream_client_port);
try
{
// Set Expedited forwarding https://datatracker.ietf.org/doc/html/rfc3246
stream.set_tos(0b101110);
}
catch (std::exception& e)
{
U_LOG_I("Failed to set IP ToS to Expedited Forwarding: %s", e.what());
}
}
void wivrn_connection::send_control(const to_headset::control_packets & packet)