From 642ca4997a42c936cd4e93d0afb4583f0a8f6297 Mon Sep 17 00:00:00 2001 From: xiongguangjie Date: Thu, 22 Sep 2022 01:07:10 +0800 Subject: [PATCH] add more dump --- srt/Packet.hpp | 2 +- srt/SrtTransport.cpp | 8 ++++++-- srt/Statistic.cpp | 19 +++++++++++++++++++ srt/Statistic.hpp | 3 ++- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/srt/Packet.hpp b/srt/Packet.hpp index c2d86a1f..601bf94f 100644 --- a/srt/Packet.hpp +++ b/srt/Packet.hpp @@ -15,7 +15,7 @@ namespace SRT { using namespace toolkit; -static const size_t HDR_SIZE = 4; // packet header size = SRT_PH_E_SIZE * sizeof(uint32_t) +static const size_t HDR_SIZE = 16; // packet header size = SRT_PH_E_SIZE * sizeof(uint32_t) // Can also be calculated as: sizeof(struct ether_header) + sizeof(struct ip) + sizeof(struct udphdr). static const size_t UDP_HDR_SIZE = 28; // 20 bytes IPv4 + 8 bytes of UDP { u16 sport, dport, len, csum }. diff --git a/srt/SrtTransport.cpp b/srt/SrtTransport.cpp index f607a00d..80db04a7 100644 --- a/srt/SrtTransport.cpp +++ b/srt/SrtTransport.cpp @@ -105,7 +105,7 @@ void SrtTransport::inputSockData(uint8_t *buf, int len, struct sockaddr_storage if(_handleshake_timer){ _handleshake_timer.reset(); } - _pkt_recv_rate_context->inputPacket(_now,len-HDR_SIZE); + _pkt_recv_rate_context->inputPacket(_now,len+UDP_HDR_SIZE); //_recv_rate_context->inputPacket(_now, len); handleDataPacket(buf, len, addr); @@ -484,7 +484,11 @@ void SrtTransport::sendACKPacket() { pkt->pkt_recv_rate = _pkt_recv_rate_context->getPacketRecvRate(recv_rate); pkt->estimated_link_capacity = _estimated_link_capacity_context->getEstimatedLinkCapacity(); pkt->recv_rate = recv_rate; - TraceL<pkt_recv_rate<<" pkt/s "<estimated_link_capacity<<" pkt/s (cap)"; + if(pkt->pkt_recv_rate == 0){ + TraceL<pkt_recv_rate<<" pkt/s "<estimated_link_capacity<<" pkt/s (cap)"; + TraceL<<_pkt_recv_rate_context->dump(); + } + pkt->storeToData(); _ack_send_timestamp[pkt->ack_number] = _now; _last_ack_pkt_seq_num = pkt->last_ack_pkt_seq_number; diff --git a/srt/Statistic.cpp b/srt/Statistic.cpp index 0456bcc8..8b069f50 100644 --- a/srt/Statistic.cpp +++ b/srt/Statistic.cpp @@ -58,6 +58,25 @@ uint32_t PacketRecvRateContext::getPacketRecvRate(uint32_t &bytesps) { } + +std::string PacketRecvRateContext::dump(){ + _StrPrinter printer; + printer <<"dur array : "; + for (size_t i = 0; i < SIZE; i++) + { + printer<<_ts_arr[i]<<" "; + } + printer <<"\r\n"; + + printer <<"size array : "; + for (size_t i = 0; i < SIZE; i++) + { + printer<<_size_arr[i]<<" "; + } + printer <<"\r\n"; + + return std::move(printer); +} EstimatedLinkCapacityContext::EstimatedLinkCapacityContext(TimePoint start) : _start(start) { for (size_t i = 0; i < SIZE; i++) { _dur_probe_arr[i] = 1000; diff --git a/srt/Statistic.hpp b/srt/Statistic.hpp index 18d562c1..245e55e4 100644 --- a/srt/Statistic.hpp +++ b/srt/Statistic.hpp @@ -12,6 +12,7 @@ public: ~PacketRecvRateContext() = default; void inputPacket(TimePoint &ts,size_t len = 0); uint32_t getPacketRecvRate(uint32_t& bytesps); + std::string dump(); static const int SIZE = 16; private: TimePoint _last_arrive_time; @@ -30,7 +31,7 @@ public: } void inputPacket(TimePoint &ts,DataPacket::Ptr& pkt); uint32_t getEstimatedLinkCapacity(); - static const int SIZE = 16; + static const int SIZE = 64; private: void probe1Arrival(TimePoint &ts,const DataPacket::Ptr& pkt, bool unordered); void probe2Arrival(TimePoint &ts,const DataPacket::Ptr& pkt);