|
Lines 646-658
void TcpSocketImpl::SendEmptyPacket (uin
|
Link Here
|
|---|
|
| 646 |
m_tcp->SendPacket (p, header, m_endPoint->GetLocalAddress (), |
646 |
m_tcp->SendPacket (p, header, m_endPoint->GetLocalAddress (), |
| 647 |
m_remoteAddress); |
647 |
m_remoteAddress); |
| 648 |
Time rto = m_rtt->RetransmitTimeout (); |
648 |
Time rto = m_rtt->RetransmitTimeout (); |
| 649 |
if (flags & TcpHeader::SYN) |
649 |
bool hasSyn = flags & TcpHeader::SYN; |
|
|
650 |
bool hasFin = flags & TcpHeader::FIN; |
| 651 |
if (hasSyn) |
| 650 |
{ |
652 |
{ |
| 651 |
rto = m_cnTimeout; |
653 |
rto = m_cnTimeout; |
| 652 |
m_cnTimeout = m_cnTimeout + m_cnTimeout; |
654 |
m_cnTimeout = m_cnTimeout + m_cnTimeout; |
| 653 |
m_cnCount--; |
655 |
m_cnCount--; |
| 654 |
} |
656 |
} |
| 655 |
if (m_retxEvent.IsExpired () ) //no outstanding timer |
657 |
if (m_retxEvent.IsExpired () && (hasSyn || hasFin) ) //no outstanding timer |
| 656 |
{ |
658 |
{ |
| 657 |
NS_LOG_LOGIC ("Schedule retransmission timeout at time " |
659 |
NS_LOG_LOGIC ("Schedule retransmission timeout at time " |
| 658 |
<< Simulator::Now ().GetSeconds () << " to expire at time " |
660 |
<< Simulator::Now ().GetSeconds () << " to expire at time " |
|
Lines 746-751
bool TcpSocketImpl::ProcessPacketAction
|
Link Here
|
|---|
|
| 746 |
Ptr<Ipv4> ipv4 = m_node->GetObject<Ipv4> (); |
748 |
Ptr<Ipv4> ipv4 = m_node->GetObject<Ipv4> (); |
| 747 |
switch (a) |
749 |
switch (a) |
| 748 |
{ |
750 |
{ |
|
|
751 |
case ACK_TX: |
| 752 |
if(tcpHeader.GetFlags() & TcpHeader::FIN) |
| 753 |
{ |
| 754 |
++m_nextRxSequence; //bump this to account for the FIN |
| 755 |
} |
| 756 |
SendEmptyPacket (TcpHeader::ACK); |
| 757 |
break; |
| 749 |
case SYN_ACK_TX: |
758 |
case SYN_ACK_TX: |
| 750 |
NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action SYN_ACK_TX"); |
759 |
NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action SYN_ACK_TX"); |
| 751 |
// m_remotePort = InetSocketAddress::ConvertFrom (fromAddress).GetPort (); |
760 |
// m_remotePort = InetSocketAddress::ConvertFrom (fromAddress).GetPort (); |
|
Lines 768-786
bool TcpSocketImpl::ProcessPacketAction
|
Link Here
|
|---|
|
| 768 |
p, tcpHeader,fromAddress); |
777 |
p, tcpHeader,fromAddress); |
| 769 |
return true; |
778 |
return true; |
| 770 |
} |
779 |
} |
| 771 |
// This is the cloned endpoint |
780 |
// This is the cloned endpoint |
| 772 |
m_endPoint->SetPeer (m_remoteAddress, m_remotePort); |
781 |
NS_ASSERT (m_state == SYN_RCVD); |
| 773 |
if (ipv4->GetIfIndexForDestination (m_remoteAddress, localIfIndex)) |
782 |
m_endPoint->SetPeer (m_remoteAddress, m_remotePort); |
| 774 |
{ |
783 |
if (ipv4->GetIfIndexForDestination (m_remoteAddress, localIfIndex)) |
| 775 |
m_localAddress = ipv4->GetAddress (localIfIndex); |
784 |
{ |
| 776 |
m_endPoint->SetLocalAddress (m_localAddress); |
785 |
m_localAddress = ipv4->GetAddress (localIfIndex); |
| 777 |
// Leave local addr in the portmap to any, as the path from |
786 |
m_endPoint->SetLocalAddress (m_localAddress); |
| 778 |
// remote can change and packets can arrive on different interfaces |
787 |
// Leave local addr in the portmap to any, as the path from |
| 779 |
//m_endPoint->SetLocalAddress (Ipv4Address::GetAny()); |
788 |
// remote can change and packets can arrive on different interfaces |
| 780 |
} |
789 |
//m_endPoint->SetLocalAddress (Ipv4Address::GetAny()); |
| 781 |
// TCP SYN consumes one byte |
790 |
} |
| 782 |
m_nextRxSequence = tcpHeader.GetSequenceNumber() + SequenceNumber(1); |
791 |
// TCP SYN consumes one byte |
| 783 |
SendEmptyPacket (TcpHeader::SYN | TcpHeader::ACK); |
792 |
m_nextRxSequence = tcpHeader.GetSequenceNumber() + SequenceNumber(1); |
|
|
793 |
SendEmptyPacket (TcpHeader::SYN | TcpHeader::ACK); |
| 784 |
break; |
794 |
break; |
| 785 |
case ACK_TX_1: |
795 |
case ACK_TX_1: |
| 786 |
NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action ACK_TX_1"); |
796 |
NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action ACK_TX_1"); |
|
Lines 845-850
bool TcpSocketImpl::ProcessPacketAction
|
Link Here
|
|---|
|
| 845 |
{ |
855 |
{ |
| 846 |
NewRx (p, tcpHeader, fromAddress); |
856 |
NewRx (p, tcpHeader, fromAddress); |
| 847 |
} |
857 |
} |
|
|
858 |
++m_nextRxSequence; //bump this to account for the FIN |
| 848 |
States_t saveState = m_state; // Used to see if app responds |
859 |
States_t saveState = m_state; // Used to see if app responds |
| 849 |
NS_LOG_LOGIC ("TcpSocketImpl " << this |
860 |
NS_LOG_LOGIC ("TcpSocketImpl " << this |
| 850 |
<< " peer close, state " << m_state); |
861 |
<< " peer close, state " << m_state); |
|
Lines 879-885
bool TcpSocketImpl::ProcessPacketAction
|
Link Here
|
|---|
|
| 879 |
CommonNewAck (tcpHeader.GetAckNumber (), true); |
890 |
CommonNewAck (tcpHeader.GetAckNumber (), true); |
| 880 |
break; |
891 |
break; |
| 881 |
default: |
892 |
default: |
| 882 |
break; |
893 |
return ProcessAction (a); |
| 883 |
} |
894 |
} |
| 884 |
return true; |
895 |
return true; |
| 885 |
} |
896 |
} |