From 3bce9bfdce707313de4f9cccdc867abd9edf82df Mon Sep 17 00:00:00 2001 From: Mauro Sardara Date: Fri, 7 Feb 2020 20:00:06 +0100 Subject: [HICN-508] [HICN-509] [HICN-506] Manifest rework Change-Id: I992205148910be008d66b5acb7f6f1365770f9e8 Signed-off-by: Mauro Sardara --- libtransport/src/hicn/transport/protocols/rtc.h | 106 ++++++++++++------------ 1 file changed, 52 insertions(+), 54 deletions(-) (limited to 'libtransport/src/hicn/transport/protocols/rtc.h') diff --git a/libtransport/src/hicn/transport/protocols/rtc.h b/libtransport/src/hicn/transport/protocols/rtc.h index 2b9ed10a6..9e1731e96 100644 --- a/libtransport/src/hicn/transport/protocols/rtc.h +++ b/libtransport/src/hicn/transport/protocols/rtc.h @@ -15,12 +15,12 @@ #pragma once -#include #include +#include #include +#include #include -#include #include // algorithm state @@ -35,26 +35,27 @@ #define HICN_TIMESTAMP_SIZE 8 // bytes #define HICN_RTC_INTEREST_LIFETIME 1000 // ms -//rtt measurement -//normal interests for data goes from 0 to -//HICN_MIN_PROBE_SEQ, the rest is reserverd for -//probes +// rtt measurement +// normal interests for data goes from 0 to +// HICN_MIN_PROBE_SEQ, the rest is reserverd for +// probes #define HICN_MIN_PROBE_SEQ 0xefffffff #define HICN_MAX_PROBE_SEQ 0xffffffff // controller constant -#define HICN_ROUND_LEN 200 // ms interval of time on which - // we take decisions / measurements +#define HICN_ROUND_LEN \ + 200 // ms interval of time on which + // we take decisions / measurements #define HICN_MAX_RTX 10 #define HICN_MAX_RTX_SIZE 1024 #define HICN_MAX_RTX_MAX_AGE 10000 -#define HICN_MIN_RTT_WIN 30 // rounds -#define HICN_MIN_INTER_ARRIVAL_GAP 100 //ms +#define HICN_MIN_RTT_WIN 30 // rounds +#define HICN_MIN_INTER_ARRIVAL_GAP 100 // ms // cwin #define HICN_INITIAL_CWIN 1 // packets #define HICN_INITIAL_CWIN_MAX 100000 // packets -#define HICN_MIN_CWIN 10 // packets +#define HICN_MIN_CWIN 10 // packets #define HICN_WIN_INCREASE_FACTOR 1.5 #define HICN_WIN_DECREASE_FACTOR 0.9 @@ -70,30 +71,23 @@ #define HICN_MICRO_IN_A_SEC 1000000 #define HICN_MILLI_IN_A_SEC 1000 - namespace transport { namespace protocol { -enum packetState { - sent_, - nacked_, - received_, - timeout1_, - timeout2_, - lost_ -}; +enum packetState { sent_, nacked_, received_, timeout1_, timeout2_, lost_ }; typedef enum packetState packetState_t; struct sentInterest { uint64_t transmissionTime; - uint32_t sequence; //sequence number of the interest sent - //to handle seq % buffer_size - packetState_t state; //see packet state + uint32_t sequence; // sequence number of the interest sent + // to handle seq % buffer_size + packetState_t state; // see packet state }; -class RTCTransportProtocol : public TransportProtocol, public Reassembly { +class RTCTransportProtocol : public TransportProtocol, + public DatagramReassembly { public: RTCTransportProtocol(interface::ConsumerSocket *icnet_socket); @@ -133,11 +127,16 @@ class RTCTransportProtocol : public TransportProtocol, public Reassembly { bool onNack(const ContentObject &content_object, bool rtx); void onContentObject(Interest::Ptr &&interest, ContentObject::Ptr &&content_object) override; - void returnContentToApplication(const ContentObject &content_object); + void onPacketDropped(Interest::Ptr &&interest, + ContentObject::Ptr &&content_object) override {} + void onReassemblyFailed(std::uint32_t missing_segment) override {} TRANSPORT_ALWAYS_INLINE virtual void reassemble( ContentObject::Ptr &&content_object) override { - returnContentToApplication(*content_object); + auto read_buffer = content_object->getPayload(); + read_buffer->trimStart(HICN_TIMESTAMP_SIZE); + Reassembly::read_buffer_ = std::move(read_buffer); + Reassembly::notifyApplication(); } // controller var @@ -151,36 +150,36 @@ class RTCTransportProtocol : public TransportProtocol, public Reassembly { // names/packets var uint32_t actualSegment_; uint32_t inflightInterestsCount_; - //map seq to rtx + // map seq to rtx std::map interestRetransmissions_; bool rtx_timer_used_; std::unique_ptr rtx_timer_; std::vector inflightInterests_; - uint32_t lastSegNacked_; //indicates the segment id in the last received - // past Nack. we do not ask for retransmissions - //for samething that is older than this value. - uint32_t lastReceived_; //segment of the last content object received - //indicates the base of the window on the client - uint64_t lastReceivedTime_; //time at which we recevied the - //lastReceived_ packet - - //sentinel - //if all packets in the window get lost we need something that - //wakes up our consumer socket. Interest timeouts set to 1 sec - //expire too late. This timers expire much sooner and if it - //detects that all the interest in the window may be lost - //it sends all of them again + uint32_t lastSegNacked_; // indicates the segment id in the last received + // past Nack. we do not ask for retransmissions + // for samething that is older than this value. + uint32_t lastReceived_; // segment of the last content object received + // indicates the base of the window on the client + uint64_t lastReceivedTime_; // time at which we recevied the + // lastReceived_ packet + + // sentinel + // if all packets in the window get lost we need something that + // wakes up our consumer socket. Interest timeouts set to 1 sec + // expire too late. This timers expire much sooner and if it + // detects that all the interest in the window may be lost + // it sends all of them again std::unique_ptr sentinel_timer_; - uint64_t lastEvent_; //time at which we removed a pending - //interest from the window + uint64_t lastEvent_; // time at which we removed a pending + // interest from the window std::unordered_map packets_in_window_; - //rtt probes - //the RTC transport tends to overestimate the RTT - //du to the production time on the server side - //once per second we send an interest for wich we know - //we will get a nack. This nack will keep our estimation - //close to the reality + // rtt probes + // the RTC transport tends to overestimate the RTT + // du to the production time on the server side + // once per second we send an interest for wich we know + // we will get a nack. This nack will keep our estimation + // close to the reality std::unique_ptr probe_timer_; uint64_t time_sent_probe_; uint32_t probe_seq_number_; @@ -203,10 +202,10 @@ class RTCTransportProtocol : public TransportProtocol, public Reassembly { uint32_t rounds_; uint32_t roundsWithoutNacks_; - //we keep track of up two paths (if only one path is in use - //the two values in the vector will be the same) - //position 0 stores the path with minRTT - //position 1 stores the path with maxRTT + // we keep track of up two paths (if only one path is in use + // the two values in the vector will be the same) + // position 0 stores the path with minRTT + // position 1 stores the path with maxRTT uint32_t producerPathLabels_[2]; std::unordered_map> pathTable_; @@ -219,7 +218,6 @@ class RTCTransportProtocol : public TransportProtocol, public Reassembly { unsigned protocolState_; bool initied; - TransportStatistics stats_; }; } // namespace protocol -- cgit 1.2.3-korg