21 #include "ns3/assert.h" 
   23 #include "ns3/nstime.h" 
   24 #include "ns3/boolean.h" 
   25 #include "ns3/object-vector.h" 
   27 #include "ns3/packet.h" 
   29 #include "ns3/simulator.h" 
   30 #include "ns3/ipv4-route.h" 
   31 #include "ns3/ipv6-route.h" 
   58 #undef NS_LOG_APPEND_CONTEXT 
   59 #define NS_LOG_APPEND_CONTEXT                                   \ 
   60   if (m_node) { std::clog << Simulator::Now ().GetSeconds () << " [node " << m_node->GetId () << "] "; }  
   70     .AddConstructor<TcpL4Protocol> ()
 
   71     .AddAttribute (
"RttEstimatorType",
 
   72                    "Type of RttEstimator objects.",
 
   76     .AddAttribute (
"SocketType",
 
   77                    "Socket type of TCP objects.",
 
   81     .AddAttribute (
"SocketList", 
"The list of sockets associated to this protocol.",
 
   84                    MakeObjectVectorChecker<TcpSocketBase> ())
 
  115   Ptr<Node> node = this->GetObject<Node> ();
 
  116   Ptr<Ipv4> ipv4 = this->GetObject<Ipv4> ();
 
  121       if ((node != 0) && (ipv4 != 0 || ipv6 != 0))
 
  125           tcpFactory->SetTcp (
this);
 
  189   socket->SetTcp (
this);
 
  190   socket->SetRtt (rtt);
 
  232   NS_LOG_FUNCTION (
this << localAddress << localPort << peerAddress << peerPort);
 
  234                                 peerAddress, peerPort);
 
  276   NS_LOG_FUNCTION (
this << localAddress << localPort << peerAddress << peerPort);
 
  278                                  peerAddress, peerPort);
 
  307                                  << 
" flags "<< std::hex << (int)tcpHeader.
GetFlags () << std::dec
 
  308                                  << 
" data size " << packet->
GetSize ());
 
  316   NS_LOG_LOGIC (
"TcpL4Protocol "<<
this<<
" received a packet");
 
  320   if (endPoints.empty ())
 
  322       if (this->GetObject<Ipv6L3Protocol> () != 0)
 
  324           NS_LOG_LOGIC (
"  No Ipv4 endpoints matched on TcpL4Protocol, trying Ipv6 "<<
this);
 
  328           return (this->
Receive (packet, src, dst, fakeInterface));
 
  331       NS_LOG_LOGIC (
"  No endpoints matched on TcpL4Protocol "<<
this);
 
  332       std::ostringstream oss;
 
  333       oss<<
"  destination IP: ";
 
  349               header.SetSequenceNumber (header.GetAckNumber ());
 
  367   NS_ASSERT_MSG (endPoints.size () == 1, 
"Demux returned more than one endpoint");
 
  368   NS_LOG_LOGIC (
"TcpL4Protocol "<<
this<<
" forwarding up to endpoint/socket");
 
  369   (*endPoints.begin ())->ForwardUp (packet, ipHeader, tcpHeader.
GetSourcePort (), 
 
  399                                  << 
" flags "<< std::hex << (int)tcpHeader.
GetFlags () << std::dec
 
  400                                  << 
" data size " << packet->
GetSize ());
 
  408   NS_LOG_LOGIC (
"TcpL4Protocol "<<
this<<
" received a packet");
 
  412   if (endPoints.empty ())
 
  414       NS_LOG_LOGIC (
"  No IPv6 endpoints matched on TcpL4Protocol "<<
this);
 
  415       std::ostringstream oss;
 
  416       oss<<
"  destination IP: ";
 
  432               header.SetSequenceNumber (header.GetAckNumber ());
 
  450   NS_ASSERT_MSG (endPoints.size () == 1, 
"Demux returned more than one endpoint");
 
  451   NS_LOG_LOGIC (
"TcpL4Protocol "<<
this<<
" forwarding up to endpoint/socket");
 
  452   (*endPoints.begin ())->ForwardUp (packet, src, dst, tcpHeader.
GetSourcePort ());
 
  461   NS_LOG_FUNCTION (
this << packet << saddr << daddr << sport << dport << oif);
 
  505   NS_LOG_FUNCTION (
this << packet << saddr << daddr << sport << dport << oif);
 
  531       if (ipv6->GetRoutingProtocol () != 0)
 
  533           route = ipv6->GetRoutingProtocol ()->RouteOutput (packet, header, oif, errno_);
 
  540       ipv6->Send (packet, saddr, daddr, 
PROT_NUMBER, route);
 
  551                                  << 
" flags " << std::hex << (int)outgoing.
GetFlags () << std::dec
 
  552                                  << 
" data size " << packet->
GetSize ());
 
  588     NS_FATAL_ERROR (
"Trying to use Tcp on a node without an Ipv4 interface");
 
  598                                  << 
" flags " << std::hex << (int)outgoing.
GetFlags () << std::dec
 
  599                                  << 
" data size " << packet->
GetSize ());
 
  627       if (ipv6->GetRoutingProtocol () != 0)
 
  629           route = ipv6->GetRoutingProtocol ()->RouteOutput (packet, header, oif, errno_);
 
  639     NS_FATAL_ERROR (
"Trying to use Tcp on a node without an Ipv6 interface");