equal
deleted
inserted
replaced
29 #include "ipv4-l4-demux.h" |
29 #include "ipv4-l4-demux.h" |
30 #include "ns3/simulation-singleton.h" |
30 #include "ns3/simulation-singleton.h" |
31 #include "tcp-typedefs.h" |
31 #include "tcp-typedefs.h" |
32 #include "ns3/simulator.h" |
32 #include "ns3/simulator.h" |
33 #include "ns3/packet.h" |
33 #include "ns3/packet.h" |
|
34 #include "ns3/trace-source-accessor.h" |
34 |
35 |
35 #include <algorithm> |
36 #include <algorithm> |
36 |
37 |
37 NS_LOG_COMPONENT_DEFINE ("TcpSocket"); |
38 NS_LOG_COMPONENT_DEFINE ("TcpSocket"); |
38 |
39 |
39 using namespace std; |
40 using namespace std; |
40 |
41 |
41 namespace ns3 { |
42 namespace ns3 { |
|
43 |
|
44 NS_OBJECT_ENSURE_REGISTERED (TcpSocket); |
|
45 |
|
46 TypeId |
|
47 TcpSocket::GetTypeId () |
|
48 { |
|
49 static TypeId tid = TypeId("ns3::TcpSocket") |
|
50 .SetParent<Socket> () |
|
51 .AddTraceSource ("CongestionWindow", |
|
52 "The TCP connection's congestion window", |
|
53 MakeTraceSourceAccessor (&TcpSocket::m_cWnd)) |
|
54 ; |
|
55 return tid; |
|
56 } |
42 |
57 |
43 TcpSocket::TcpSocket () |
58 TcpSocket::TcpSocket () |
44 : m_skipRetxResched (false), |
59 : m_skipRetxResched (false), |
45 m_dupAckCount (0), |
60 m_dupAckCount (0), |
46 m_delAckCount (0), |
61 m_delAckCount (0), |
678 case ACK_TX_1: |
693 case ACK_TX_1: |
679 NS_LOG_LOGIC ("TcpSocket " << this <<" Action ACK_TX_1"); |
694 NS_LOG_LOGIC ("TcpSocket " << this <<" Action ACK_TX_1"); |
680 // TCP SYN consumes one byte |
695 // TCP SYN consumes one byte |
681 m_nextRxSequence = tcpHeader.GetSequenceNumber() + SequenceNumber(1); |
696 m_nextRxSequence = tcpHeader.GetSequenceNumber() + SequenceNumber(1); |
682 m_nextTxSequence = tcpHeader.GetAckNumber (); |
697 m_nextTxSequence = tcpHeader.GetAckNumber (); |
|
698 m_firstPendingSequence = m_nextTxSequence; //bug 166 |
683 NS_LOG_DEBUG ("TcpSocket " << this << " ACK_TX_1" << |
699 NS_LOG_DEBUG ("TcpSocket " << this << " ACK_TX_1" << |
684 " nextRxSeq " << m_nextRxSequence); |
700 " nextRxSeq " << m_nextRxSequence); |
685 SendEmptyPacket (TcpHeader::ACK); |
701 SendEmptyPacket (TcpHeader::ACK); |
686 m_rxWindowSize = tcpHeader.GetWindowSize (); |
702 m_rxWindowSize = tcpHeader.GetWindowSize (); |
687 if (tcpHeader.GetAckNumber () > m_highestRxAck) |
703 if (tcpHeader.GetAckNumber () > m_highestRxAck) |
897 |
913 |
898 uint32_t TcpSocket::Window () |
914 uint32_t TcpSocket::Window () |
899 { |
915 { |
900 NS_LOG_FUNCTION; |
916 NS_LOG_FUNCTION; |
901 NS_LOG_LOGIC ("TcpSocket::Window() "<<this); |
917 NS_LOG_LOGIC ("TcpSocket::Window() "<<this); |
902 return std::min (m_rxWindowSize, m_cWnd); |
918 return std::min (m_rxWindowSize, m_cWnd.Get()); |
903 } |
919 } |
904 |
920 |
905 uint32_t TcpSocket::AvailableWindow () |
921 uint32_t TcpSocket::AvailableWindow () |
906 { |
922 { |
907 NS_LOG_FUNCTION; |
923 NS_LOG_FUNCTION; |
1118 NS_LOG_LOGIC ("TcpSocket " << this << " NewCWnd SlowStart, cWnd " << m_cWnd |
1134 NS_LOG_LOGIC ("TcpSocket " << this << " NewCWnd SlowStart, cWnd " << m_cWnd |
1119 << " sst " << m_ssThresh); |
1135 << " sst " << m_ssThresh); |
1120 } |
1136 } |
1121 else |
1137 else |
1122 { // Congestion avoidance mode, adjust by (ackBytes*segSize) / cWnd |
1138 { // Congestion avoidance mode, adjust by (ackBytes*segSize) / cWnd |
1123 double adder = ((double) m_segmentSize * m_segmentSize) / m_cWnd; |
1139 double adder = ((double) m_segmentSize * m_segmentSize) / m_cWnd.Get(); |
1124 if (adder < 1.0) |
1140 if (adder < 1.0) |
1125 { |
1141 { |
1126 adder = 1.0; |
1142 adder = 1.0; |
1127 } |
1143 } |
1128 m_cWnd += (uint32_t) adder; |
1144 m_cWnd += (uint32_t) adder; |