Add expedited forwarding ToS flag in stream socket
This commit is contained in:
@@ -133,6 +133,15 @@ void xrt::drivers::wivrn::UDP::set_receive_buffer_size(int size)
|
|||||||
setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(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()
|
void xrt::drivers::wivrn::TCP::init()
|
||||||
{
|
{
|
||||||
int nodelay = 1;
|
int nodelay = 1;
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ public:
|
|||||||
void subscribe_multicast(in6_addr address);
|
void subscribe_multicast(in6_addr address);
|
||||||
void unsubscribe_multicast(in6_addr address);
|
void unsubscribe_multicast(in6_addr address);
|
||||||
void set_receive_buffer_size(int size);
|
void set_receive_buffer_size(int size);
|
||||||
|
void set_tos(int type_of_service);
|
||||||
};
|
};
|
||||||
|
|
||||||
class TCP : public fd_base
|
class TCP : public fd_base
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "wivrn_connection.h"
|
#include "wivrn_connection.h"
|
||||||
|
#include "util/u_logging.h"
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
@@ -27,6 +28,15 @@ wivrn_connection::wivrn_connection(TCP && tcp, in6_addr address) :
|
|||||||
{
|
{
|
||||||
stream.bind(stream_server_port);
|
stream.bind(stream_server_port);
|
||||||
stream.connect(address, stream_client_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)
|
void wivrn_connection::send_control(const to_headset::control_packets & packet)
|
||||||
|
|||||||
Reference in New Issue
Block a user