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" 
   59 #undef NS_LOG_APPEND_CONTEXT 
   60 #define NS_LOG_APPEND_CONTEXT                                   \ 
   61   if (m_node) { std::clog << Simulator::Now ().GetSeconds () << " [node " << m_node->GetId () << "] "; }  
   71     .AddConstructor<TcpL4Protocol> ()
 
   72     .AddAttribute (
"RttEstimatorType",
 
   73                    "Type of RttEstimator objects.",
 
   77     .AddAttribute (
"SocketType",
 
   78                    "Socket type of TCP objects.",
 
   82     .AddAttribute (
"SocketList", 
"The list of sockets associated to this protocol.",
 
   85                    MakeObjectVectorChecker<TcpSocketBase> ())
 
  116   Ptr<Node> node = this->GetObject<Node> ();
 
  117   Ptr<Ipv4> ipv4 = this->GetObject<Ipv4> ();
 
  122       if ((node != 0) && (ipv4 != 0 || ipv6 != 0))
 
  126           tcpFactory->SetTcp (
this);
 
  190   socket->SetTcp (
this);
 
  191   socket->SetRtt (rtt);
 
  234   NS_LOG_FUNCTION (
this << localAddress << localPort << peerAddress << peerPort);
 
  236                                 peerAddress, peerPort);
 
  278   NS_LOG_FUNCTION (
this << localAddress << localPort << peerAddress << peerPort);
 
  280                                  peerAddress, peerPort);
 
  292                             uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
 
  294                             const uint8_t payload[8])
 
  296   NS_LOG_FUNCTION (
this << icmpSource << icmpTtl << icmpType << icmpCode << icmpInfo 
 
  297                         << payloadSource << payloadDestination);
 
  299   src = payload[0] << 8;
 
  301   dst = payload[2] << 8;
 
  307       endPoint->
ForwardIcmp (icmpSource, icmpTtl, icmpType, icmpCode, icmpInfo);
 
  311       NS_LOG_DEBUG (
"no endpoint found source=" << payloadSource <<
 
  312                     ", destination="<<payloadDestination<<
 
  313                     ", src=" << src << 
", dst=" << dst);
 
  319                             uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
 
  321                             const uint8_t payload[8])
 
  323   NS_LOG_FUNCTION (
this << icmpSource << icmpTtl << icmpType << icmpCode << icmpInfo 
 
  324                         << payloadSource << payloadDestination);
 
  326   src = payload[0] << 8;
 
  328   dst = payload[2] << 8;
 
  334       endPoint->
ForwardIcmp (icmpSource, icmpTtl, icmpType, icmpCode, icmpInfo);
 
  338       NS_LOG_DEBUG (
"no endpoint found source=" << payloadSource <<
 
  339                     ", destination="<<payloadDestination<<
 
  340                     ", src=" << src << 
", dst=" << dst);
 
  363                                  << 
" flags "<< std::hex << (int)tcpHeader.
GetFlags () << std::dec
 
  364                                  << 
" data size " << packet->
GetSize ());
 
  372   NS_LOG_LOGIC (
"TcpL4Protocol "<<
this<<
" received a packet");
 
  376   if (endPoints.empty ())
 
  378       if (this->GetObject<Ipv6L3Protocol> () != 0)
 
  380           NS_LOG_LOGIC (
"  No Ipv4 endpoints matched on TcpL4Protocol, trying Ipv6 "<<
this);
 
  387           return (this->
Receive (packet, ipv6Header, fakeInterface));
 
  390       NS_LOG_LOGIC (
"  No endpoints matched on TcpL4Protocol "<<
this);
 
  391       std::ostringstream oss;
 
  392       oss<<
"  destination IP: ";
 
  408               header.SetSequenceNumber (header.GetAckNumber ());
 
  426   NS_ASSERT_MSG (endPoints.size () == 1, 
"Demux returned more than one endpoint");
 
  427   NS_LOG_LOGIC (
"TcpL4Protocol "<<
this<<
" forwarding up to endpoint/socket");
 
  428   (*endPoints.begin ())->ForwardUp (packet, ipHeader, tcpHeader.
GetSourcePort (), 
 
  455                                  << 
" receiving seq " << tcpHeader.GetSequenceNumber ()
 
  456                                  << 
" ack " << tcpHeader.GetAckNumber ()
 
  457                                  << 
" flags "<< std::hex << (int)tcpHeader.GetFlags () << std::dec
 
  458                                  << 
" data size " << packet->
GetSize ());
 
  460   if(!tcpHeader.IsChecksumOk ())
 
  466   NS_LOG_LOGIC (
"TcpL4Protocol "<<
this<<
" received a packet");
 
  470   if (endPoints.empty ())
 
  472       NS_LOG_LOGIC (
"  No IPv6 endpoints matched on TcpL4Protocol "<<
this);
 
  473       std::ostringstream oss;
 
  474       oss<<
"  destination IP: ";
 
  476       oss<<
" destination port: "<< tcpHeader.GetDestinationPort ()<<
" source IP: ";
 
  478       oss<<
" source port: "<<tcpHeader.GetSourcePort ();
 
  490               header.SetSequenceNumber (header.GetAckNumber ());
 
  498           header.SetSourcePort (tcpHeader.GetDestinationPort ());
 
  499           header.SetDestinationPort (tcpHeader.GetSourcePort ());
 
  508   NS_ASSERT_MSG (endPoints.size () == 1, 
"Demux returned more than one endpoint");
 
  509   NS_LOG_LOGIC (
"TcpL4Protocol "<<
this<<
" forwarding up to endpoint/socket");
 
  510   (*endPoints.begin ())->ForwardUp (packet, ipHeader, tcpHeader.GetSourcePort (), interface);
 
  519   NS_LOG_FUNCTION (
this << packet << saddr << daddr << sport << dport << oif);
 
  545       if (ipv4->GetRoutingProtocol () != 0)
 
  547           route = ipv4->GetRoutingProtocol ()->RouteOutput (packet, header, oif, errno_);
 
  554       ipv4->Send (packet, saddr, daddr, 
PROT_NUMBER, route);
 
  563   NS_LOG_FUNCTION (
this << packet << saddr << daddr << sport << dport << oif);
 
  589       if (ipv6->GetRoutingProtocol () != 0)
 
  591           route = ipv6->GetRoutingProtocol ()->RouteOutput (packet, header, oif, errno_);
 
  598       ipv6->Send (packet, saddr, daddr, 
PROT_NUMBER, route);
 
  609                                  << 
" flags " << std::hex << (int)outgoing.
GetFlags () << std::dec
 
  610                                  << 
" data size " << packet->
GetSize ());
 
  635       if (ipv4->GetRoutingProtocol () != 0)
 
  637           route = ipv4->GetRoutingProtocol ()->RouteOutput (packet, header, oif, errno_);
 
  647     NS_FATAL_ERROR (
"Trying to use Tcp on a node without an Ipv4 interface");
 
  657                                  << 
" flags " << std::hex << (int)outgoing.
GetFlags () << std::dec
 
  658                                  << 
" data size " << packet->
GetSize ());
 
  687       if (ipv6->GetRoutingProtocol () != 0)
 
  689           route = ipv6->GetRoutingProtocol ()->RouteOutput (packet, header, oif, errno_);
 
  699     NS_FATAL_ERROR (
"Trying to use Tcp on a node without an Ipv6 interface");
 
Ptr< const AttributeAccessor > MakeObjectVectorAccessor(U T::*memberContainer)
 
Ptr< Socket > CreateSocket(void)
Create a TCP socket. 
 
TypeId m_socketTypeId
The socket TypeId. 
 
#define NS_LOG_FUNCTION(parameters)
 
Ptr< Node > m_node
the node this stack is associated with 
 
virtual void SetDownTarget6(IpL4Protocol::DownTargetCallback6 cb)
This method allows a caller to set the current down target callback set for this L4 protocol (IPv6 ca...
 
virtual IpL4Protocol::DownTargetCallback6 GetDownTarget6(void) const 
This method allows a caller to get the current down target callback set for this L4 protocol (IPv6 ca...
 
std::list< Ipv6EndPoint * > EndPoints
Container of the IPv6 endpoints. 
 
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
 
void Send(Ptr< Packet > packet, Ipv6Address source, Ipv6Address destination, uint8_t protocol, Ptr< Ipv6Route > route)
Higher-level layers call this method to send a packet down the stack to the MAC and PHY layers...
 
IPv6 layer implementation. 
 
EndPoints Lookup(Ipv6Address dst, uint16_t dport, Ipv6Address src, uint16_t sport, Ptr< Ipv6Interface > incomingInterface)
lookup for a match with all the parameters. 
 
static bool ChecksumEnabled(void)
 
Ipv6EndPoint * Allocate6(void)
Allocate an IPv6 Endpoint. 
 
void Send(Ptr< Packet > packet, Ipv4Address saddr, Ipv4Address daddr, uint16_t sport, uint16_t dport, Ptr< NetDevice > oif=0)
Send a packet via TCP (IPv4) 
 
bool IsNull(void) const 
Check for null implementation. 
 
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
 
virtual void ReceiveIcmp(Ipv4Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo, Ipv4Address payloadSource, Ipv4Address payloadDestination, const uint8_t payload[8])
Called from lower-level layers to send the ICMP packet up in the stack. 
 
void SetTypeId(TypeId tid)
 
uint32_t GetSize(void) const 
 
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
 
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function. 
 
static TypeId GetTypeId(void)
Get the type ID. 
 
SocketErrno
Enumeration of the possible errors returned by a socket. 
 
#define NS_FATAL_ERROR(msg)
fatal error handling 
 
void DeAllocate(Ipv4EndPoint *endPoint)
Remove an IPv4 Endpoint. 
 
virtual void NotifyNewAggregate()
This method is invoked whenever two sets of objects are aggregated together. 
 
SequenceNumber< uint32_t, int32_t > SequenceNumber32
 
Demultiplexes packets to various transport layer endpoints. 
 
static TypeId GetTypeId(void)
Get the type ID. 
 
Ptr< Object > Create(void) const 
 
virtual enum IpL4Protocol::RxStatus Receive(Ptr< Packet > p, Ipv4Header const &header, Ptr< Ipv4Interface > incomingInterface)
Called from lower-level layers to send the packet up in the stack. 
 
Base class for all RTT Estimators. 
 
virtual IpL4Protocol::DownTargetCallback GetDownTarget(void) const 
This method allows a caller to get the current down target callback set for this L4 protocol (IPv4 ca...
 
Ipv6EndPoint * Allocate(void)
Allocate a Ipv6EndPoint. 
 
hold objects of type ns3::TypeId 
 
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
 
void Print(std::ostream &os) const 
Print this address to the given output stream. 
 
A base class for implementation of a stream socket using TCP. 
 
void AggregateObject(Ptr< Object > other)
 
#define NS_LOG_LOGIC(msg)
 
std::vector< Ptr< TcpSocketBase > > m_sockets
list of sockets 
 
void DeAllocate(Ipv6EndPoint *endPoint)
Remove a end point. 
 
static const uint8_t PROT_NUMBER
protocol number (0x6) 
 
virtual void NotifyNewAggregate(void)
This method is invoked whenever two sets of objects are aggregated together. 
 
Access to the Ipv4 forwarding table, interfaces, and configuration. 
 
uint32_t PeekHeader(Header &header) const 
Deserialize but does not remove the header from the internal buffer. 
 
Ipv6EndPointDemux * m_endPoints6
A list of IPv6 end points. 
 
void ForwardIcmp(Ipv4Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo)
Forward the ICMP packet to the upper level. 
 
virtual int GetProtocolNumber(void) const 
 
virtual void SetNode(Ptr< Node > node)
Set the associated node. 
 
Ipv6EndPoint * SimpleLookup(Ipv6Address dst, uint16_t dport, Ipv6Address src, uint16_t sport)
Simple lookup for a four-tuple match. 
 
virtual void Send(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol, Ptr< Ipv4Route > route)=0
 
Ipv4EndPoint * SimpleLookup(Ipv4Address daddr, uint16_t dport, Ipv4Address saddr, uint16_t sport)
simple lookup for a match with all the parameters. 
 
void SendPacket(Ptr< Packet >, const TcpHeader &, Ipv4Address, Ipv4Address, Ptr< NetDevice > oif=0)
 
L4 Protocol abstract base class. 
 
Ipv4EndPoint * Allocate(void)
Allocate an IPv4 Endpoint. 
 
EndPoints Lookup(Ipv4Address daddr, uint16_t dport, Ipv4Address saddr, uint16_t sport, Ptr< Ipv4Interface > incomingInterface)
lookup for a match with all the parameters. 
 
Ipv4EndPointDemux * m_endPoints
A list of IPv4 end points. 
 
void SetNode(Ptr< Node > node)
Set node associated with this stack. 
 
#define NS_ASSERT_MSG(condition, message)
 
Describes an IPv6 address. 
 
instantiate subclasses of ns3::Object. 
 
Ipv4 addresses are stored in host order in this class. 
 
std::list< Ipv4EndPoint * > EndPoints
Container of the IPv4 endpoints. 
 
static TypeId GetTypeId(void)
Get the type ID. 
 
Demultiplexor for end points. 
 
#define NS_LOG_DEBUG(msg)
 
A representation of an internet IPv6 endpoint/connection. 
 
virtual void SetDownTarget(IpL4Protocol::DownTargetCallback cb)
This method allows a caller to set the current down target callback set for this L4 protocol (IPv4 ca...
 
NS_LOG_COMPONENT_DEFINE("TcpL4Protocol")
 
TypeId m_rttTypeId
The RTT Estimator TypeId. 
 
Ipv4Address GetIpv4MappedAddress() const 
Return the Ipv4 address. 
 
void Nullify(void)
Discard the implementation, set it to null. 
 
void ForwardIcmp(Ipv6Address src, uint8_t ttl, uint8_t type, uint8_t code, uint32_t info)
Forward the ICMP packet to the upper level. 
 
#define NS_LOG_ERROR(msg)
 
contain a set of ns3::Object pointers. 
 
void DeAllocate(Ipv4EndPoint *endPoint)
Remove a end point. 
 
static Ipv6Address MakeIpv4MappedAddress(Ipv4Address addr)
Make the Ipv4-mapped IPv6 address. 
 
Ptr< T > GetObject(void) const 
 
bool IsIpv4MappedAddress() const 
If the address is an IPv4-mapped address. 
 
a unique identifier for an interface. 
 
TypeId SetParent(TypeId tid)
 
IpL4Protocol::DownTargetCallback6 m_downTarget6
Callback to send packets over IPv6. 
 
void AddHeader(const Header &header)
Add header to this packet. 
 
A representation of an internet endpoint/connection. 
 
IpL4Protocol::DownTargetCallback m_downTarget
Callback to send packets over IPv4. 
 
Ipv4EndPoint * Allocate(void)
Allocate a Ipv4EndPoint.