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 2017/12/06 06:22:05 UTC
[trafficserver] branch quic-latest updated: Implement ack block
section parser
This is an automated email from the ASF dual-hosted git repository.
maskit 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 e86b83a Implement ack block section parser
e86b83a is described below
commit e86b83ac32771808d9f4d8a4f7de937621615625
Author: Masakazu Kitajo <ma...@apache.org>
AuthorDate: Wed Dec 6 15:07:41 2017 +0900
Implement ack block section parser
---
iocore/net/quic/QUICFrame.cc | 29 +++++++++-----
iocore/net/quic/QUICFrame.h | 7 +++-
iocore/net/quic/test/test_QUICFrame.cc | 71 ++++++++++++++++++++++++++--------
3 files changed, 78 insertions(+), 29 deletions(-)
diff --git a/iocore/net/quic/QUICFrame.cc b/iocore/net/quic/QUICFrame.cc
index 3bb8822..1a1c151 100644
--- a/iocore/net/quic/QUICFrame.cc
+++ b/iocore/net/quic/QUICFrame.cc
@@ -496,26 +496,26 @@ QUICAckFrame::AckBlockSection::AckBlockSection(uint64_t first_ack_block_length)
QUICAckFrame::AckBlock::AckBlock(const uint8_t *buf, uint8_t ack_block_length)
{
- uint8_t gap = buf[0];
- uint64_t length = QUICTypeUtil::read_nbytes_as_uint(buf + 1, ack_block_length);
- this->_data = (static_cast<uint64_t>(gap) << 56) + length;
+ this->_gap = buf[0];
+ this->_length = QUICTypeUtil::read_nbytes_as_uint(buf + 1, ack_block_length);
}
QUICAckFrame::AckBlock::AckBlock(uint8_t gap, uint64_t length)
{
- this->_data = (static_cast<uint64_t>(gap) << 56) + length;
+ this->_gap = gap;
+ this->_length = length;
}
uint8_t
QUICAckFrame::AckBlock::gap() const
{
- return this->_data >> 56;
+ return this->_gap;
}
uint64_t
QUICAckFrame::AckBlock::length() const
{
- return this->_data & 0x0000FFFFFFFFFFFF;
+ return this->_length;
}
uint8_t
@@ -558,7 +558,11 @@ QUICAckFrame::AckBlockSection::store(uint8_t *buf, size_t *len) const
uint64_t
QUICAckFrame::AckBlockSection::first_ack_block_length() const
{
- return this->_first_ack_block_length;
+ if (this->_buf) {
+ return QUICTypeUtil::read_nbytes_as_uint(this->_buf, this->_ack_block_length);
+ } else {
+ return this->_first_ack_block_length;
+ }
}
void
@@ -590,9 +594,14 @@ QUICAckFrame::AckBlockSection::end() const
QUICAckFrame::AckBlockSection::const_iterator::const_iterator(uint8_t index, const uint8_t *buf, uint8_t num_blocks,
uint8_t ack_block_length)
{
- this->_index = index;
- this->_buf = buf;
- this->_current_block = AckBlock(buf, ack_block_length);
+ this->_index = index;
+ this->_buf = buf;
+ this->_ack_block_length = ack_block_length;
+ if (index < num_blocks) {
+ this->_current_block = AckBlock(buf + ack_block_length + (1 + ack_block_length) * index, ack_block_length);
+ } else {
+ this->_current_block = {static_cast<uint8_t>(0), 0ULL};
+ }
}
QUICAckFrame::AckBlockSection::const_iterator::const_iterator(uint8_t index, const std::vector<QUICAckFrame::AckBlock> *ack_block)
diff --git a/iocore/net/quic/QUICFrame.h b/iocore/net/quic/QUICFrame.h
index 43c52b5..2acacb4 100644
--- a/iocore/net/quic/QUICFrame.h
+++ b/iocore/net/quic/QUICFrame.h
@@ -102,7 +102,8 @@ public:
LINK(QUICAckFrame::AckBlock, link);
private:
- uint64_t _data = 0;
+ uint8_t _gap = 0;
+ uint64_t _length = 0;
};
class AckBlockSection
@@ -121,7 +122,8 @@ public:
++(this->_index);
if (this->_buf) {
- // TODO Parse Ack Block
+ this->_current_block =
+ AckBlock(this->_buf + this->_ack_block_length + (1 + this->_ack_block_length) * this->_index, this->_ack_block_length);
} else {
if (this->_ack_blocks->size() == this->_index) {
this->_current_block = {static_cast<uint8_t>(0), 0ULL};
@@ -148,6 +150,7 @@ public:
private:
uint8_t _index;
const uint8_t *_buf;
+ uint8_t _ack_block_length;
const std::vector<QUICAckFrame::AckBlock> *_ack_blocks = nullptr;
QUICAckFrame::AckBlock _current_block = {static_cast<uint8_t>(0), 0ULL};
};
diff --git a/iocore/net/quic/test/test_QUICFrame.cc b/iocore/net/quic/test/test_QUICFrame.cc
index 1e2969c..84a6fbb 100644
--- a/iocore/net/quic/test/test_QUICFrame.cc
+++ b/iocore/net/quic/test/test_QUICFrame.cc
@@ -237,23 +237,60 @@ TEST_CASE("Store STREAM Frame", "[quic]")
TEST_CASE("Load Ack Frame 1", "[quic]")
{
- // 0 Ack Block, 8 bit packet number length, 8 bit block length
- uint8_t buf1[] = {
- 0xA0, // 101NLLMM
- 0x12, // Largest Acknowledged
- 0x34, 0x56, // Ack Delay
- 0x00, // Ack Block Section
- };
- std::shared_ptr<const QUICFrame> frame1 = QUICFrameFactory::create(buf1, sizeof(buf1));
- CHECK(frame1->type() == QUICFrameType::ACK);
- CHECK(frame1->size() == 5);
- std::shared_ptr<const QUICAckFrame> ackFrame1 = std::dynamic_pointer_cast<const QUICAckFrame>(frame1);
- CHECK(ackFrame1 != nullptr);
- CHECK(ackFrame1->has_ack_blocks() == false);
- CHECK(ackFrame1->largest_acknowledged() == 0x12);
- CHECK(ackFrame1->ack_delay() == 0x3456);
-
- // TODO: 1 Ack Block
+ SECTION("0 Ack Block, 8 bit packet number length, 8 bit block length")
+ {
+ uint8_t buf1[] = {
+ 0xA0, // 101NLLMM
+ 0x12, // Largest Acknowledged
+ 0x34, 0x56, // Ack Delay
+ 0x00, // Ack Block Section
+ };
+ std::shared_ptr<const QUICFrame> frame1 = QUICFrameFactory::create(buf1, sizeof(buf1));
+ CHECK(frame1->type() == QUICFrameType::ACK);
+ CHECK(frame1->size() == 5);
+ std::shared_ptr<const QUICAckFrame> ackFrame1 = std::dynamic_pointer_cast<const QUICAckFrame>(frame1);
+ CHECK(ackFrame1 != nullptr);
+ CHECK(ackFrame1->has_ack_blocks() == false);
+ CHECK(ackFrame1->largest_acknowledged() == 0x12);
+ CHECK(ackFrame1->ack_delay() == 0x3456);
+ }
+
+ SECTION("2 Ack Block, 8 bit packet number length, 8 bit block length")
+ {
+ uint8_t buf1[] = {
+ 0xB0, // 101NLLMM
+ 0x02, // Num Blocks
+ 0x12, // Largest Acknowledged
+ 0x34, 0x56, // Ack Delay
+ 0x01, // Ack Block Section (First ACK Block Length)
+ 0x02, // Ack Block Section (Gap 1)
+ 0x03, // Ack Block Section (ACK Block 1 Length)
+ 0x04, // Ack Block Section (Gap 2)
+ 0x05, // Ack Block Section (ACK Block 2 Length)
+ };
+
+ std::shared_ptr<const QUICFrame> frame1 = QUICFrameFactory::create(buf1, sizeof(buf1));
+ CHECK(frame1->type() == QUICFrameType::ACK);
+ CHECK(frame1->size() == 10);
+ std::shared_ptr<const QUICAckFrame> ackFrame1 = std::dynamic_pointer_cast<const QUICAckFrame>(frame1);
+ CHECK(ackFrame1 != nullptr);
+ CHECK(ackFrame1->largest_acknowledged() == 0x12);
+ CHECK(ackFrame1->ack_delay() == 0x3456);
+ CHECK(ackFrame1->num_blocks() == 2);
+ CHECK(ackFrame1->has_ack_blocks() == true);
+ const QUICAckFrame::AckBlockSection *section = ackFrame1->ack_block_section();
+ CHECK(section->first_ack_block_length() == 0x01);
+ auto ite = section->begin();
+ CHECK(ite != section->end());
+ CHECK(ite->gap() == 2);
+ CHECK(ite->length() == 3);
+ ++ite;
+ CHECK(ite != section->end());
+ CHECK(ite->gap() == 4);
+ CHECK(ite->length() == 5);
+ ++ite;
+ CHECK(ite == section->end());
+ }
}
TEST_CASE("Load Ack Frame 2", "[quic]")
--
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].