You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ma...@apache.org on 2018/04/02 04:43:53 UTC
[trafficserver] branch quic-latest updated: QUIC: Check congestion
window when sending packet
This is an automated email from the ASF dual-hosted git repository.
masaori pushed a commit to branch quic-latest
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/quic-latest by this push:
new 90d8668 QUIC: Check congestion window when sending packet
90d8668 is described below
commit 90d86680169a72c94235e3591a9d72d8eb1ff467
Author: scw00 <sc...@apache.org>
AuthorDate: Sat Mar 31 10:10:02 2018 +0800
QUIC: Check congestion window when sending packet
---
iocore/net/QUICNetVConnection.cc | 10 ++++--
iocore/net/quic/QUICCongestionController.cc | 48 +++++++++++++++++++++++++++++
iocore/net/quic/QUICLossDetector.h | 9 ++++++
3 files changed, 65 insertions(+), 2 deletions(-)
diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index 63b8a56..540b39c 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -197,7 +197,7 @@ QUICNetVConnection::start()
// Create frame handlers
this->_stream_manager = new QUICStreamManager(this->connection_id(), this->_application_map);
- this->_congestion_controller = new QUICCongestionController();
+ this->_congestion_controller = new QUICCongestionController(this->connection_id());
this->_loss_detector = new QUICLossDetector(this, this->_congestion_controller);
this->_remote_flow_controller = new QUICRemoteConnectionFlowController(0);
this->_local_flow_controller = new QUICLocalConnectionFlowController(0);
@@ -935,10 +935,16 @@ QUICNetVConnection::_state_common_send_packet()
QUICPacket *packet;
SCOPED_MUTEX_LOCK(packet_transmitter_lock, this->_packet_transmitter_mutex, this_ethread());
- uint32_t packet_count = this->_packet_send_queue.size;
+ uint32_t packet_count = 0;
while ((packet = this->_packet_send_queue.dequeue()) != nullptr) {
+ if (!this->_congestion_controller->check_credit()) {
+ this->_packet_send_queue.push(packet);
+ break;
+ }
+
this->_packet_handler->send_packet(*packet, this);
this->_loss_detector->on_packet_sent(QUICPacketUPtr(packet, &QUICPacketDeleter::delete_packet));
+ packet_count++;
}
QUIC_INCREMENT_DYN_STAT_EX(QUICStats::total_packets_sent_stat, packet_count);
diff --git a/iocore/net/quic/QUICCongestionController.cc b/iocore/net/quic/QUICCongestionController.cc
index 44f4de9..de607a4 100644
--- a/iocore/net/quic/QUICCongestionController.cc
+++ b/iocore/net/quic/QUICCongestionController.cc
@@ -24,6 +24,18 @@
#include <ts/Diags.h>
#include <QUICLossDetector.h>
+#define QUICCCDebug(fmt, ...) \
+ Debug("quic_cc", "[%" PRIx64 "] " \
+ "window: %" PRIu32 " bytes: %" PRIu32 " ssthresh: %" PRIu32 " " fmt, \
+ static_cast<uint64_t>(this->_connection_id), this->_congestion_window, this->_bytes_in_flight, this->_ssthresh, \
+ ##__VA_ARGS__)
+
+#define QUICCCError(fmt, ...) \
+ Error("quic_cc", "[%" PRIx64 "] " \
+ "window: %" PRIu32 " bytes: %" PRIu32 " ssthresh: %" PRIu32 " " fmt, \
+ static_cast<uint64_t>(this->_connection_id), this->_congestion_window, this->_bytes_in_flight, this->_ssthresh, \
+ ##__VA_ARGS__)
+
// 4.7.1. Constants of interest
constexpr static uint16_t DEFAULT_MSS = 1460;
constexpr static uint32_t INITIAL_WINDOW = 10 * DEFAULT_MSS;
@@ -35,6 +47,11 @@ QUICCongestionController::QUICCongestionController()
this->_congestion_window = INITIAL_WINDOW;
}
+QUICCongestionController::QUICCongestionController(QUICConnectionId connection_id) : _connection_id(connection_id)
+{
+ this->_congestion_window = INITIAL_WINDOW;
+}
+
void
QUICCongestionController::on_packet_sent(size_t bytes_sent)
{
@@ -59,9 +76,11 @@ QUICCongestionController::on_packet_acked(QUICPacketNumber acked_packet_number,
if (this->_congestion_window < this->_ssthresh) {
// Slow start.
this->_congestion_window += acked_packet_size;
+ QUICCCDebug("slow start window chaged");
} else {
// Congestion avoidance.
this->_congestion_window += DEFAULT_MSS * acked_packet_size / this->_congestion_window;
+ QUICCCDebug("Congestion avoidance window changed");
}
}
@@ -80,6 +99,7 @@ QUICCongestionController::on_packets_lost(std::map<QUICPacketNumber, PacketInfo
this->_congestion_window *= LOSS_REDUCTION_FACTOR;
this->_congestion_window = std::max(this->_congestion_window, MINIMUM_WINDOW);
this->_ssthresh = this->_congestion_window;
+ QUICCCDebug("packet lost, window changed");
}
}
@@ -88,3 +108,31 @@ QUICCongestionController::on_retransmission_timeout_verified()
{
this->_congestion_window = MINIMUM_WINDOW;
}
+
+bool
+QUICCongestionController::check_credit() const
+{
+ if (this->_bytes_in_flight >= this->_congestion_window) {
+ QUICCCDebug("Congestion control pending");
+ }
+
+ return this->_bytes_in_flight < this->_congestion_window;
+}
+
+uint32_t
+QUICCongestionController::bytes_in_flight() const
+{
+ return this->_bytes_in_flight;
+}
+
+uint32_t
+QUICCongestionController::congestion_window() const
+{
+ return this->_congestion_window;
+}
+
+uint32_t
+QUICCongestionController::current_ssthresh() const
+{
+ return this->_ssthresh;
+}
diff --git a/iocore/net/quic/QUICLossDetector.h b/iocore/net/quic/QUICLossDetector.h
index 3fd79fa..202e6a7 100644
--- a/iocore/net/quic/QUICLossDetector.h
+++ b/iocore/net/quic/QUICLossDetector.h
@@ -50,12 +50,19 @@ class QUICCongestionController
{
public:
QUICCongestionController();
+ QUICCongestionController(QUICConnectionId connection_id);
virtual ~QUICCongestionController() {}
void on_packet_sent(size_t bytes_sent);
void on_packet_acked(QUICPacketNumber acked_packet_number, size_t acked_packet_size);
virtual void on_packets_lost(std::map<QUICPacketNumber, PacketInfo &> packets);
void on_retransmission_timeout_verified();
+ bool check_credit() const;
+
+ // Debug
+ uint32_t bytes_in_flight() const;
+ uint32_t congestion_window() const;
+ uint32_t current_ssthresh() const;
private:
// 4.7.2. Variables of interest
@@ -64,6 +71,8 @@ private:
QUICPacketNumber _end_of_recovery = 0;
uint32_t _ssthresh = UINT32_MAX;
+ QUICConnectionId _connection_id = 0;
+
bool _in_recovery(QUICPacketNumber packet_number);
};
--
To stop receiving notification emails like this one, please contact
masaori@apache.org.