nic_router: rework round-trip-time handling
Do not use two times the RTT for the lifetime of links but use it as it is configured to simplify the usage of the router. Internally, use Microseconds/Duration type instead of plain integers. Ref #2490
This commit is contained in:
parent
71bd9a1f10
commit
e5b9a6cc8b
|
@ -178,7 +178,7 @@ append config {
|
||||||
<start name="nic_router" caps="200">
|
<start name="nic_router" caps="200">
|
||||||
<resource name="RAM" quantum="10M"/>
|
<resource name="RAM" quantum="10M"/>
|
||||||
<provides><service name="Nic"/></provides>
|
<provides><service name="Nic"/></provides>
|
||||||
<config rtt_sec="3" verbose="no">
|
<config rtt_sec="6" verbose="no">
|
||||||
|
|
||||||
<policy label_prefix="udp_client_1" domain="udp_client_1" />
|
<policy label_prefix="udp_client_1" domain="udp_client_1" />
|
||||||
<policy label_prefix="http_client_3" domain="http_client_3" />
|
<policy label_prefix="http_client_3" domain="http_client_3" />
|
||||||
|
|
|
@ -197,7 +197,7 @@ append config {
|
||||||
<start name="nic_router" caps="200" priority="-1">
|
<start name="nic_router" caps="200" priority="-1">
|
||||||
<resource name="RAM" quantum="10M"/>
|
<resource name="RAM" quantum="10M"/>
|
||||||
<provides><service name="Nic"/></provides>
|
<provides><service name="Nic"/></provides>
|
||||||
<config rtt_sec="3" verbose="no">
|
<config rtt_sec="6" verbose="no">
|
||||||
|
|
||||||
<policy label_prefix="udp_client_1" domain="udp_client_1" />
|
<policy label_prefix="udp_client_1" domain="udp_client_1" />
|
||||||
<policy label_prefix="http_client_3" domain="http_client_3" />
|
<policy label_prefix="http_client_3" domain="http_client_3" />
|
||||||
|
|
|
@ -220,18 +220,18 @@ link states so you should choose it with care. If it is too low, replies that
|
||||||
normally need no routing rule may get lost. If it is too high, link states are
|
normally need no routing rule may get lost. If it is too high, link states are
|
||||||
held longer than necessary.
|
held longer than necessary.
|
||||||
|
|
||||||
In general, each link state is discarded after a duration of two times the
|
In general, each link state is discarded after a duration of the round-trip
|
||||||
round-trip time without a matching packet. For UDP link states, this is the
|
time without a matching packet. For UDP link states, this is the only rule and
|
||||||
only rule and better known as hole punching. It allows peers to keep alive a
|
better known as hole punching. It allows peers to keep alive a UDP
|
||||||
UDP pseudo-connection through the router by frequently sending empty packets.
|
pseudo-connection through the router by frequently sending empty packets. The
|
||||||
The need for such a pseudo-connection arises from the router's demand to
|
need for such a pseudo-connection arises from the router's demand to support
|
||||||
support NAT for UDP transfers and the consequence of keeping the corresponding
|
NAT for UDP transfers and the consequence of keeping the corresponding mapping
|
||||||
mapping information.
|
information.
|
||||||
|
|
||||||
The lifetime management of TCP link states, in contrast, is more complex. In
|
The lifetime management of TCP link states, in contrast, is more complex. In
|
||||||
addition to the common timeout, they may be discarded even if they still
|
addition to the common timeout, they may be discarded even if they still
|
||||||
receive packets. This is the case when the router observed the four-way
|
receive packets. This is the case when the router observed the four-way
|
||||||
termination handshake of TCP and two times the round-trip time has passed.
|
termination handshake of TCP and the round-trip time has passed.
|
||||||
|
|
||||||
|
|
||||||
Configuring NAT
|
Configuring NAT
|
||||||
|
|
|
@ -23,29 +23,23 @@ using namespace Net;
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
|
|
||||||
/***************
|
Microseconds Configuration::_init_rtt(Xml_node const node)
|
||||||
** Utilities **
|
|
||||||
***************/
|
|
||||||
|
|
||||||
static unsigned read_rtt_sec(Xml_node const node)
|
|
||||||
{
|
{
|
||||||
unsigned const rtt_sec = node.attribute_value("rtt_sec", 0UL);
|
unsigned rtt_sec = node.attribute_value("rtt_sec", 0UL);
|
||||||
if (!rtt_sec) {
|
if (!rtt_sec) {
|
||||||
warning("fall back to default rtt_sec=\"3\"");
|
warning("fall back to default rtt_sec=\"",
|
||||||
return 3;
|
(unsigned)DEFAULT_RTT_SEC, "\"");
|
||||||
|
rtt_sec = DEFAULT_RTT_SEC;
|
||||||
}
|
}
|
||||||
return rtt_sec;
|
return Microseconds(rtt_sec * 1000 * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*******************
|
Configuration::Configuration(Xml_node const node,
|
||||||
** Configuration **
|
Allocator &alloc)
|
||||||
*******************/
|
|
||||||
|
|
||||||
Configuration::Configuration(Xml_node const node, Allocator &alloc)
|
|
||||||
:
|
:
|
||||||
_alloc(alloc), _verbose(node.attribute_value("verbose", false)),
|
_alloc(alloc), _verbose(node.attribute_value("verbose", false)),
|
||||||
_rtt_sec(read_rtt_sec(node)), _node(node)
|
_rtt(_init_rtt(node)), _node(node)
|
||||||
{
|
{
|
||||||
/* read domains */
|
/* read domains */
|
||||||
node.for_each_sub_node("domain", [&] (Xml_node const node) {
|
node.for_each_sub_node("domain", [&] (Xml_node const node) {
|
||||||
|
|
|
@ -17,6 +17,9 @@
|
||||||
/* local includes */
|
/* local includes */
|
||||||
#include <domain.h>
|
#include <domain.h>
|
||||||
|
|
||||||
|
/* Genode includes */
|
||||||
|
#include <os/duration.h>
|
||||||
|
|
||||||
namespace Genode { class Allocator; }
|
namespace Genode { class Allocator; }
|
||||||
|
|
||||||
namespace Net { class Configuration; }
|
namespace Net { class Configuration; }
|
||||||
|
@ -26,14 +29,18 @@ class Net::Configuration
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Genode::Allocator &_alloc;
|
Genode::Allocator &_alloc;
|
||||||
bool const _verbose;
|
bool const _verbose;
|
||||||
unsigned const _rtt_sec;
|
Genode::Microseconds const _rtt;
|
||||||
Domain_tree _domains;
|
Domain_tree _domains;
|
||||||
Genode::Xml_node const _node;
|
Genode::Xml_node const _node;
|
||||||
|
|
||||||
|
Genode::Microseconds _init_rtt(Genode::Xml_node const node);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
enum { DEFAULT_RTT_SEC = 6 };
|
||||||
|
|
||||||
Configuration(Genode::Xml_node const node, Genode::Allocator &alloc);
|
Configuration(Genode::Xml_node const node, Genode::Allocator &alloc);
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,10 +48,10 @@ class Net::Configuration
|
||||||
** Accessors **
|
** Accessors **
|
||||||
***************/
|
***************/
|
||||||
|
|
||||||
bool verbose() const { return _verbose; }
|
bool verbose() const { return _verbose; }
|
||||||
unsigned rtt_sec() const { return _rtt_sec; }
|
Genode::Microseconds rtt() const { return _rtt; }
|
||||||
Domain_tree &domains() { return _domains; }
|
Domain_tree &domains() { return _domains; }
|
||||||
Genode::Xml_node node() const { return _node; }
|
Genode::Xml_node node() const { return _node; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _CONFIGURATION_H_ */
|
#endif /* _CONFIGURATION_H_ */
|
||||||
|
|
|
@ -124,7 +124,7 @@ Link::Link(Interface &cln_interface,
|
||||||
_server_port_alloc(srv_port_alloc),
|
_server_port_alloc(srv_port_alloc),
|
||||||
_server(srv_interface, srv_id, *this),
|
_server(srv_interface, srv_id, *this),
|
||||||
_close_timeout(timer, *this, &Link::_handle_close_timeout),
|
_close_timeout(timer, *this, &Link::_handle_close_timeout),
|
||||||
_close_timeout_us(_config.rtt_sec() * 2 * 1000 * 1000),
|
_close_timeout_us(_config.rtt()),
|
||||||
_protocol(protocol)
|
_protocol(protocol)
|
||||||
{
|
{
|
||||||
_close_timeout.schedule(_close_timeout_us);
|
_close_timeout.schedule(_close_timeout_us);
|
||||||
|
|
|
@ -124,8 +124,6 @@ class Net::Link : public Link_list::Element
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
using Signal_handler = Genode::Signal_handler<Link>;
|
|
||||||
|
|
||||||
Configuration &_config;
|
Configuration &_config;
|
||||||
Link_side _client;
|
Link_side _client;
|
||||||
Pointer<Port_allocator_guard> const _server_port_alloc;
|
Pointer<Port_allocator_guard> const _server_port_alloc;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user