View | Details | Raw Unified | Return to bug 242
Collapse All | Expand All

(-)a/examples/tcp-large-transfer.cc (+1 lines)
 Lines 132-137   int main (int argc, char *argv[]) Link Here 
132
132
133
  ApplicationContainer apps = sink.Install (n1n2.Get (1));
133
  ApplicationContainer apps = sink.Install (n1n2.Get (1));
134
  apps.Start (Seconds (0.0));
134
  apps.Start (Seconds (0.0));
135
  apps.Stop (Seconds (3.0));
135
136
136
  // Create a source to send packets from n0.  Instead of a full Application
137
  // Create a source to send packets from n0.  Instead of a full Application
137
  // and the helper APIs you might see in other example files, this example
138
  // and the helper APIs you might see in other example files, this example
(-)a/src/internet-stack/tcp-socket-impl.cc (-16 / +27 lines)
 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
}
(-)a/src/internet-stack/tcp-typedefs.h (-15 / +15 lines)
 Lines 63-83   typedef enum { Link Here 
63
typedef enum {
63
typedef enum {
64
  NO_ACT,       // 0
64
  NO_ACT,       // 0
65
  ACK_TX,       // 1
65
  ACK_TX,       // 1
66
  ACK_TX_1,     // ACK response to syn
66
  ACK_TX_1,     // 2 - ACK response to syn
67
  RST_TX,       // 2
67
  RST_TX,       // 3
68
  SYN_TX,       // 3
68
  SYN_TX,       // 4
69
  SYN_ACK_TX,   // 4
69
  SYN_ACK_TX,   // 5
70
  FIN_TX,       // 5
70
  FIN_TX,       // 6
71
  FIN_ACK_TX,   // 6
71
  FIN_ACK_TX,   // 7
72
  NEW_ACK,      // 7
72
  NEW_ACK,      // 8
73
  NEW_SEQ_RX,   // 8
73
  NEW_SEQ_RX,   // 9
74
  RETX,         // 9
74
  RETX,         // 10
75
  TX_DATA,      // 10
75
  TX_DATA,      // 11
76
  PEER_CLOSE,   // 11
76
  PEER_CLOSE,   // 12
77
  APP_CLOSED,   // 12
77
  APP_CLOSED,   // 13
78
  CANCEL_TM,    // 13
78
  CANCEL_TM,    // 14
79
  APP_NOTIFY,   // 14 - Notify app that connection failed
79
  APP_NOTIFY,   // 15 - Notify app that connection failed
80
  SERV_NOTIFY,  // 15 - Notify server tcp that connection completed
80
  SERV_NOTIFY,  // 16 - Notify server tcp that connection completed
81
  LAST_ACTION } Actions_t;
81
  LAST_ACTION } Actions_t;
82
82
83
class SA  // State/Action pair
83
class SA  // State/Action pair

Return to bug 242