@@ -19,6 +19,9 @@ TcpFlow::TcpFlow(Id a_id, std::shared_ptr<IConnection> a_conn,
1919 m_src(m_connection->get_sender ()),
2020 m_dest(m_connection->get_receiver ()),
2121 m_cc(std::move(a_cc)),
22+ m_sending_started(false ),
23+ m_init_time(0 ),
24+ m_last_ack_arrive_time(0 ),
2225 m_packet_size(a_packet_size),
2326 m_ecn_capable(a_ecn_capable),
2427 m_packets_in_flight(0 ),
@@ -30,7 +33,6 @@ TcpFlow::TcpFlow(Id a_id, std::shared_ptr<IConnection> a_conn,
3033 if (m_dest.lock () == nullptr ) {
3134 throw std::invalid_argument (" Receiver for TcpFlow is nullptr" );
3235 }
33- m_init_time = Scheduler::get_instance ().get_current_time ();
3436 initialize_flag_manager ();
3537}
3638
@@ -39,8 +41,10 @@ SizeByte TcpFlow::get_delivered_data_size() const {
3941}
4042
4143TimeNs TcpFlow::get_fct () const {
42- TimeNs now = Scheduler::get_instance ().get_current_time ();
43- return now - m_init_time;
44+ if (!m_sending_started) {
45+ return TimeNs (0 );
46+ }
47+ return m_last_ack_arrive_time - m_init_time;
4448}
4549
4650std::shared_ptr<IHost> TcpFlow::get_sender () const { return m_src.lock (); }
@@ -72,14 +76,20 @@ Packet TcpFlow::create_packet(PacketNum packet_num) {
7276}
7377
7478void TcpFlow::send_packet () {
79+ TimeNs now = Scheduler::get_instance ().get_current_time ();
80+
81+ if (!m_sending_started) {
82+ m_init_time = now;
83+ m_sending_started = true ;
84+ }
85+
7586 if (get_sending_quota () == 0 ) {
7687 LOG_WARN (
7788 fmt::format (" No sending quota for flow {}; packet not sent" , m_id));
7889 return ;
7990 }
8091 Packet packet = create_packet (m_next_packet_num++);
8192 TimeNs pacing_delay = m_cc->get_pacing_delay ();
82- TimeNs now = Scheduler::get_instance ().get_current_time ();
8393
8494 if (pacing_delay == TimeNs (0 )) {
8595 send_packet_now (std::move (packet));
@@ -182,6 +192,8 @@ void TcpFlow::update(Packet packet) {
182192 return ;
183193 }
184194
195+ m_last_ack_arrive_time = current_time;
196+
185197 if (m_acked.contains (packet.packet_num )) {
186198 LOG_WARN (fmt::format (" Got duplicate ack number {}; ignored" ,
187199 packet.packet_num ));
0 commit comments