add more dump

This commit is contained in:
xiongguangjie 2022-09-22 01:07:10 +08:00
parent 533f35dac4
commit 642ca4997a
4 changed files with 28 additions and 4 deletions

View File

@ -15,7 +15,7 @@ namespace SRT {
using namespace toolkit; 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). // 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 }. static const size_t UDP_HDR_SIZE = 28; // 20 bytes IPv4 + 8 bytes of UDP { u16 sport, dport, len, csum }.

View File

@ -105,7 +105,7 @@ void SrtTransport::inputSockData(uint8_t *buf, int len, struct sockaddr_storage
if(_handleshake_timer){ if(_handleshake_timer){
_handleshake_timer.reset(); _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); //_recv_rate_context->inputPacket(_now, len);
handleDataPacket(buf, len, addr); handleDataPacket(buf, len, addr);
@ -484,7 +484,11 @@ void SrtTransport::sendACKPacket() {
pkt->pkt_recv_rate = _pkt_recv_rate_context->getPacketRecvRate(recv_rate); pkt->pkt_recv_rate = _pkt_recv_rate_context->getPacketRecvRate(recv_rate);
pkt->estimated_link_capacity = _estimated_link_capacity_context->getEstimatedLinkCapacity(); pkt->estimated_link_capacity = _estimated_link_capacity_context->getEstimatedLinkCapacity();
pkt->recv_rate = recv_rate; pkt->recv_rate = recv_rate;
if(pkt->pkt_recv_rate == 0){
TraceL<<pkt->pkt_recv_rate<<" pkt/s "<<recv_rate<<" byte/s "<<pkt->estimated_link_capacity<<" pkt/s (cap)"; TraceL<<pkt->pkt_recv_rate<<" pkt/s "<<recv_rate<<" byte/s "<<pkt->estimated_link_capacity<<" pkt/s (cap)";
TraceL<<_pkt_recv_rate_context->dump();
}
pkt->storeToData(); pkt->storeToData();
_ack_send_timestamp[pkt->ack_number] = _now; _ack_send_timestamp[pkt->ack_number] = _now;
_last_ack_pkt_seq_num = pkt->last_ack_pkt_seq_number; _last_ack_pkt_seq_num = pkt->last_ack_pkt_seq_number;

View File

@ -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) { EstimatedLinkCapacityContext::EstimatedLinkCapacityContext(TimePoint start) : _start(start) {
for (size_t i = 0; i < SIZE; i++) { for (size_t i = 0; i < SIZE; i++) {
_dur_probe_arr[i] = 1000; _dur_probe_arr[i] = 1000;

View File

@ -12,6 +12,7 @@ public:
~PacketRecvRateContext() = default; ~PacketRecvRateContext() = default;
void inputPacket(TimePoint &ts,size_t len = 0); void inputPacket(TimePoint &ts,size_t len = 0);
uint32_t getPacketRecvRate(uint32_t& bytesps); uint32_t getPacketRecvRate(uint32_t& bytesps);
std::string dump();
static const int SIZE = 16; static const int SIZE = 16;
private: private:
TimePoint _last_arrive_time; TimePoint _last_arrive_time;
@ -30,7 +31,7 @@ public:
} }
void inputPacket(TimePoint &ts,DataPacket::Ptr& pkt); void inputPacket(TimePoint &ts,DataPacket::Ptr& pkt);
uint32_t getEstimatedLinkCapacity(); uint32_t getEstimatedLinkCapacity();
static const int SIZE = 16; static const int SIZE = 64;
private: private:
void probe1Arrival(TimePoint &ts,const DataPacket::Ptr& pkt, bool unordered); void probe1Arrival(TimePoint &ts,const DataPacket::Ptr& pkt, bool unordered);
void probe2Arrival(TimePoint &ts,const DataPacket::Ptr& pkt); void probe2Arrival(TimePoint &ts,const DataPacket::Ptr& pkt);