LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2014 Natale Patriciello, <natale.patriciello@gmail.com> | 3 * Copyright (c) 2014 Natale Patriciello, <natale.patriciello@gmail.com> |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 19 matching lines...) Expand all Loading... |
30 namespace ns3 { | 30 namespace ns3 { |
31 | 31 |
32 NS_OBJECT_ENSURE_REGISTERED (TcpHighSpeed); | 32 NS_OBJECT_ENSURE_REGISTERED (TcpHighSpeed); |
33 | 33 |
34 TypeId | 34 TypeId |
35 TcpHighSpeed::GetTypeId (void) | 35 TcpHighSpeed::GetTypeId (void) |
36 { | 36 { |
37 static TypeId tid = TypeId ("ns3::TcpHighSpeed") | 37 static TypeId tid = TypeId ("ns3::TcpHighSpeed") |
38 .SetParent<TcpNewReno> () | 38 .SetParent<TcpNewReno> () |
39 .AddConstructor<TcpHighSpeed> () | 39 .AddConstructor<TcpHighSpeed> () |
| 40 .SetGroupName ("Internet") |
40 ; | 41 ; |
41 return tid; | 42 return tid; |
42 } | 43 } |
43 | 44 |
44 TcpHighSpeed::TcpHighSpeed (void) : TcpNewReno () | 45 TcpHighSpeed::TcpHighSpeed (void) : TcpNewReno () |
45 { | 46 { |
46 NS_LOG_FUNCTION (this); | 47 NS_LOG_FUNCTION (this); |
47 } | 48 } |
48 | 49 |
49 TcpHighSpeed::TcpHighSpeed (const TcpHighSpeed& sock) | 50 TcpHighSpeed::TcpHighSpeed (const TcpHighSpeed& sock) |
50 : TcpNewReno (sock) | 51 : TcpNewReno (sock) |
51 { | 52 { |
52 } | 53 } |
53 | 54 |
54 TcpHighSpeed::~TcpHighSpeed (void) | 55 TcpHighSpeed::~TcpHighSpeed (void) |
55 { | 56 { |
56 } | 57 } |
57 | 58 |
58 Ptr<TcpSocketBase> | 59 Ptr<TcpSocketBase> |
59 TcpHighSpeed::Fork (void) | 60 TcpHighSpeed::Fork (void) |
60 { | 61 { |
61 return CopyObject<TcpHighSpeed> (this); | 62 return CopyObject<TcpHighSpeed> (this); |
62 } | 63 } |
63 | 64 |
64 /* New ACK (up to seqnum seq) received. Increase cwnd and call TcpSocketBase::Ne
wAck() */ | 65 /* New ACK (up to seqnum seq) received. Increase cwnd and call TcpSocketBase::Ne
wAck() */ |
65 void | 66 void |
66 TcpHighSpeed::NewAck (const SequenceNumber32& seq) | 67 TcpHighSpeed::NewAck (const SequenceNumber32& seq) |
67 { | 68 { |
68 NS_LOG_FUNCTION (this << seq); | 69 NS_LOG_FUNCTION (this << seq); |
69 NS_LOG_LOGIC ("TcpHighSpeed receieved ACK for seq " << seq << | 70 NS_LOG_LOGIC ("TcpHighSpeed received ACK for seq " << seq << |
70 " cwnd " << m_cWnd << | 71 " cwnd " << m_cWnd << |
71 " ssthresh " << m_ssThresh); | 72 " ssthresh " << m_ssThresh); |
72 | 73 |
73 // Check for exit condition of fast recovery | 74 // Check for exit condition of fast recovery |
74 if (m_inFastRec && seq < m_recover) | 75 if (m_inFastRec && seq < m_recover) |
75 { // Partial ACK, partial window deflation (RFC2582 sec.3 bullet #5 paragrap
h 3) | 76 { // Partial ACK, partial window deflation (RFC2582 sec.3 bullet #5 paragrap
h 3) |
76 //m_cWnd -= seq - m_txBuffer->HeadSequence (); | 77 //m_cWnd -= seq - m_txBuffer->HeadSequence (); |
77 //m_cWnd += m_segmentSize; // increase cwnd | 78 //m_cWnd += m_segmentSize; // increase cwnd |
78 NS_LOG_INFO ("Partial ACK in fast recovery: cwnd set to " << m_cWnd); | 79 NS_LOG_INFO ("Partial ACK in fast recovery: cwnd set to " << m_cWnd); |
79 TcpSocketBase::NewAck (seq); // update m_nextTxSequence and send new data
if allowed by window | 80 TcpSocketBase::NewAck (seq); // update m_nextTxSequence and send new data
if allowed by window |
(...skipping 22 matching lines...) Expand all Loading... |
102 NS_LOG_INFO ("In CongAvoid, updated to cwnd " << m_cWnd << " ssthresh " <<
m_ssThresh); | 103 NS_LOG_INFO ("In CongAvoid, updated to cwnd " << m_cWnd << " ssthresh " <<
m_ssThresh); |
103 } | 104 } |
104 | 105 |
105 // Complete newAck processing | 106 // Complete newAck processing |
106 TcpSocketBase::NewAck (seq); | 107 TcpSocketBase::NewAck (seq); |
107 } | 108 } |
108 | 109 |
109 uint32_t | 110 uint32_t |
110 TcpHighSpeed::TableLookupA (uint32_t w) | 111 TcpHighSpeed::TableLookupA (uint32_t w) |
111 { | 112 { |
| 113 NS_LOG_FUNCTION (this << w); |
112 if (w <= 38) | 114 if (w <= 38) |
113 { | 115 { |
114 return 1; | 116 return 1; |
115 } | 117 } |
116 else if (w <= 118) | 118 else if (w <= 118) |
117 { | 119 { |
118 return 2; | 120 return 2; |
119 } | 121 } |
120 else if (w <= 221) | 122 else if (w <= 221) |
121 { | 123 { |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 else if (w <= 94717) | 402 else if (w <= 94717) |
401 { | 403 { |
402 return 73; | 404 return 73; |
403 } | 405 } |
404 else | 406 else |
405 { | 407 { |
406 return 73; | 408 return 73; |
407 } | 409 } |
408 } | 410 } |
409 | 411 |
410 double TcpHighSpeed::TableLookupB(uint32_t w) | 412 double TcpHighSpeed::TableLookupB (uint32_t w) |
411 { | 413 { |
412 w = static_cast<uint32_t> (w); | 414 NS_LOG_FUNCTION (this << w); |
| 415 |
413 if (w <= 38) | 416 if (w <= 38) |
414 { | 417 { |
415 return 0.50; | 418 return 0.50; |
416 } | 419 } |
417 else if (w <= 118) | 420 else if (w <= 118) |
418 { | 421 { |
419 return 0.44; | 422 return 0.44; |
420 } | 423 } |
421 else if (w <= 221) | 424 else if (w <= 221) |
422 { | 425 { |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 void | 714 void |
712 TcpHighSpeed::Loss () | 715 TcpHighSpeed::Loss () |
713 { | 716 { |
714 NS_LOG_FUNCTION (this); | 717 NS_LOG_FUNCTION (this); |
715 // w = (1-b(w))*w | 718 // w = (1-b(w))*w |
716 uint32_t segCwnd = m_cWnd / m_segmentSize; | 719 uint32_t segCwnd = m_cWnd / m_segmentSize; |
717 uint32_t oldCwnd = m_cWnd; | 720 uint32_t oldCwnd = m_cWnd; |
718 double coeffB = 1.0 - TableLookupB (segCwnd); | 721 double coeffB = 1.0 - TableLookupB (segCwnd); |
719 segCwnd = coeffB * segCwnd; | 722 segCwnd = coeffB * segCwnd; |
720 | 723 |
721 m_ssThresh = std::max (2 * m_segmentSize, m_cWnd.Get () - (segCwnd*m_segmentSi
ze)); | 724 m_ssThresh = std::max (2 * m_segmentSize, m_cWnd.Get () - (segCwnd * m_segment
Size)); |
722 m_cWnd = segCwnd * m_segmentSize; | 725 m_cWnd = segCwnd * m_segmentSize; |
723 | 726 |
724 NS_LOG_DEBUG ("HIGHSPEED LOSS. BEFORE cwnd=" << (oldCwnd/m_segmentSize) << " n
ow=" << m_cWnd/m_segmentSize | 727 NS_LOG_DEBUG ("HIGHSPEED LOSS. BEFORE cwnd=" << (oldCwnd / m_segmentSize) << "
now=" << m_cWnd / m_segmentSize |
725 << " with coeffB=" << coeffB); | 728 << " with coeffB=" << coeffB); |
726 } | 729 } |
727 | 730 |
728 /* Cut cwnd and enter fast recovery mode upon triple dupack */ | 731 /* Cut cwnd and enter fast recovery mode upon triple dupack */ |
729 void | 732 void |
730 TcpHighSpeed::DupAck (const TcpHeader& t, uint32_t count) | 733 TcpHighSpeed::DupAck (const TcpHeader& t, uint32_t count) |
731 { | 734 { |
732 NS_LOG_FUNCTION (this << count); | 735 NS_LOG_FUNCTION (this << count); |
733 if (count == m_retxThresh && !m_inFastRec) | 736 if (count == m_retxThresh && !m_inFastRec) |
734 { | 737 { |
735 Loss (); | 738 Loss (); |
(...skipping 19 matching lines...) Expand all Loading... |
755 | 758 |
756 /* Retransmit timeout */ | 759 /* Retransmit timeout */ |
757 void | 760 void |
758 TcpHighSpeed::Retransmit (void) | 761 TcpHighSpeed::Retransmit (void) |
759 { | 762 { |
760 NS_LOG_FUNCTION (this); | 763 NS_LOG_FUNCTION (this); |
761 NS_LOG_LOGIC (this << " ReTxTimeout Expired at time " << Simulator::Now ().Get
Seconds ()); | 764 NS_LOG_LOGIC (this << " ReTxTimeout Expired at time " << Simulator::Now ().Get
Seconds ()); |
762 m_inFastRec = false; | 765 m_inFastRec = false; |
763 | 766 |
764 // If erroneous timeout in closed/timed-wait state, just return | 767 // If erroneous timeout in closed/timed-wait state, just return |
765 if (m_state == CLOSED || m_state == TIME_WAIT) return; | 768 if (m_state == CLOSED || m_state == TIME_WAIT) |
| 769 { |
| 770 return; |
| 771 } |
766 // If all data are received (non-closing socket and nothing to send), just ret
urn | 772 // If all data are received (non-closing socket and nothing to send), just ret
urn |
767 if (m_state <= ESTABLISHED && m_txBuffer->HeadSequence () >= m_highTxMark) ret
urn; | 773 if (m_state <= ESTABLISHED && m_txBuffer->HeadSequence () >= m_highTxMark) |
| 774 { |
| 775 return; |
| 776 } |
768 | 777 |
769 Loss (); | 778 Loss (); |
770 | 779 |
771 m_nextTxSequence = m_txBuffer->HeadSequence (); // Restart from highest Ack | 780 m_nextTxSequence = m_txBuffer->HeadSequence (); // Restart from highest Ack |
772 NS_LOG_INFO ("RTO. Reset cwnd to " << m_cWnd << | 781 NS_LOG_INFO ("RTO. Reset cwnd to " << m_cWnd << |
773 ", ssthresh to " << m_ssThresh << ", restart from seqnum " << m_n
extTxSequence); | 782 ", ssthresh to " << m_ssThresh << ", restart from seqnum " << m_n
extTxSequence); |
774 DoRetransmit (); // Retransmit the packet | 783 DoRetransmit (); // Retransmit the packet |
775 } | 784 } |
776 | 785 |
777 } // namespace ns3 | 786 } // namespace ns3 |
LEFT | RIGHT |