From 3d4feaaaf75e2284215f2aaf964a40c745c915c6 Mon Sep 17 00:00:00 2001 From: drbob Date: Tue, 10 Jan 2012 19:40:35 +0000 Subject: [PATCH] Set a RateCap that is 75% of absolute bandwidth limit. This reduced rate is required because of the overhead associated with TCP and Relay connections: * The Internal rate is calculated based on transmitted data (a reliable stream). * The Relay rate is calculated at UDP packet level and is x1.1 - x1.2 higher than internal rate. The Relay will drop the connection if peers exceed specified level - so best to leave some head room. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-dhtmods@4773 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/pqi/pqissludp.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libretroshare/src/pqi/pqissludp.cc b/libretroshare/src/pqi/pqissludp.cc index 4f1e1ea5b..a1098d890 100644 --- a/libretroshare/src/pqi/pqissludp.cc +++ b/libretroshare/src/pqi/pqissludp.cc @@ -251,7 +251,18 @@ int pqissludp::Initiate_Connection() std::cerr << remote_addr << ")" << std::endl; tou_connect_via_relay(sockfd, &(mConnectSrcAddr), &(mConnectProxyAddr), &(remote_addr)); - parent()->setRateCap( mConnectBandwidth / 1000.0, mConnectBandwidth / 1000.0); // Set RateCap. + +/*** It seems that the UDP Layer sees x 1.2 the traffic of the SSL layer. + * We need to compensate somewhere... we drop the maximum traffic to 75% of limit + * to allow for extra lost packets etc. + * NB: If we have a lossy UDP transmission - re-transmission could cause excessive data to + * exceed the limit... This is difficult to account for without hacking the TcpOnUdp layer. + * If it is noticed as a problem - we'll deal with it then + */ +#define UDP_RELAY_TRANSPORT_OVERHEAD_FACTOR (0.7) + + parent()->setRateCap( UDP_RELAY_TRANSPORT_OVERHEAD_FACTOR * mConnectBandwidth / 1000.0, + UDP_RELAY_TRANSPORT_OVERHEAD_FACTOR * mConnectBandwidth / 1000.0); // Set RateCap. } if (0 != err)