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"    62 #undef NS_LOG_APPEND_CONTEXT    63 #define NS_LOG_APPEND_CONTEXT                                   \    64   if (m_node) { std::clog << " [node " << m_node->GetId () << "] "; }    74     .SetGroupName (
"Internet")
    76     .AddAttribute (
"RttEstimatorType",
    77                    "Type of RttEstimator objects.",
    81     .AddAttribute (
"SocketType",
    82                    "Socket type of TCP objects.",
    86     .AddAttribute (
"RecoveryType",
    87                    "Recovery type of TCP objects.",
    91     .AddAttribute (
"SocketList", 
"The list of sockets associated to this protocol.",
    94                    MakeObjectVectorChecker<TcpSocketBase> ())
   121   Ptr<Node> node = this->GetObject<Node> ();
   122   Ptr<Ipv4> ipv4 = this->GetObject<Ipv4> ();
   127       if ((node != 0) && (ipv4 != 0 || ipv6 != 0))
   131           tcpFactory->SetTcp (
this);
   198   congestionAlgorithmFactory.
SetTypeId (congestionTypeId);
   199   recoveryAlgorithmFactory.
SetTypeId (recoveryTypeId);
   207   socket->SetTcp (
this);
   208   socket->SetRtt (rtt);
   209   socket->SetCongestionControlAlgorithm (algo);
   210   socket->SetRecoveryAlgorithm (recovery);
   255   NS_LOG_FUNCTION (
this << boundNetDevice << localAddress << localPort << peerAddress << peerPort);
   257                                 localAddress, localPort,
   258                                 peerAddress, peerPort);
   301   NS_LOG_FUNCTION (
this << boundNetDevice << localAddress << localPort << peerAddress << peerPort);
   303                                  localAddress, localPort,
   304                                  peerAddress, peerPort);
   316                             uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
   318                             const uint8_t payload[8])
   320   NS_LOG_FUNCTION (
this << icmpSource << (uint16_t) icmpTtl << (uint16_t) icmpType << (uint16_t) icmpCode << icmpInfo
   321                         << payloadSource << payloadDestination);
   323   src = payload[0] << 8;
   325   dst = payload[2] << 8;
   331       endPoint->
ForwardIcmp (icmpSource, icmpTtl, icmpType, icmpCode, icmpInfo);
   335       NS_LOG_DEBUG (
"no endpoint found source=" << payloadSource <<
   336                     ", destination=" << payloadDestination <<
   337                     ", src=" << src << 
", dst=" << dst);
   343                             uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
   345                             const uint8_t payload[8])
   347   NS_LOG_FUNCTION (
this << icmpSource << (uint16_t) icmpTtl << (uint16_t) icmpType << (uint16_t) icmpCode << icmpInfo
   348                         << payloadSource << payloadDestination);
   350   src = payload[0] << 8;
   352   dst = payload[2] << 8;
   358       endPoint->
ForwardIcmp (icmpSource, icmpTtl, icmpType, icmpCode, icmpInfo);
   362       NS_LOG_DEBUG (
"no endpoint found source=" << payloadSource <<
   363                     ", destination=" << payloadDestination <<
   364                     ", src=" << src << 
", dst=" << dst);
   372   NS_LOG_FUNCTION (
this << packet << incomingTcpHeader << source << destination);
   386                                  << 
" data size " << packet->
GetSize ());
   402   NS_LOG_FUNCTION (
this << incomingHeader << incomingSAddr << incomingDAddr);
   414           outgoingTcpHeader.SetSequenceNumber (incomingHeader.
GetAckNumber ());
   428       outgoingTcpHeader.SetDestinationPort (incomingHeader.
GetSourcePort ());
   430       SendPacket (rstPacket, outgoingTcpHeader, incomingDAddr, incomingSAddr);
   439   NS_LOG_FUNCTION (
this << packet << incomingIpHeader << incomingInterface);
   450       return checksumControl;
   460   if (endPoints.empty ())
   462       if (this->GetObject<Ipv6L3Protocol> () != 0)
   464           NS_LOG_LOGIC (
"  No Ipv4 endpoints matched on TcpL4Protocol, trying Ipv6 " << 
this);
   473           return (this->
Receive (packet, ipv6Header, fakeInterface));
   476       NS_LOG_LOGIC (
"TcpL4Protocol " << 
this << 
" received a packet but"   477                     " no endpoints matched." <<
   480                     " source IP: " << incomingIpHeader.
GetSource () <<
   490   NS_ASSERT_MSG (endPoints.size () == 1, 
"Demux returned more than one endpoint");
   491   NS_LOG_LOGIC (
"TcpL4Protocol " << 
this << 
" received a packet and"   492                 " now forwarding it up to endpoint/socket");
   494   (*endPoints.begin ())->ForwardUp (packet, incomingIpHeader,
   522       return checksumControl;
   527                           incomingTcpHeader.GetDestinationPort (),
   529                           incomingTcpHeader.GetSourcePort (), interface);
   530   if (endPoints.empty ())
   532       NS_LOG_LOGIC (
"TcpL4Protocol " << 
this << 
" received a packet but"   533                     " no endpoints matched." <<
   535                     " destination port: "<< incomingTcpHeader.GetDestinationPort () <<
   537                     " source port: "<< incomingTcpHeader.GetSourcePort ());
   545   NS_ASSERT_MSG (endPoints.size () == 1, 
"Demux returned more than one endpoint");
   546   NS_LOG_LOGIC (
"TcpL4Protocol " << 
this << 
" received a packet and"   547                 " now forwarding it up to endpoint/socket");
   549   (*endPoints.begin ())->ForwardUp (packet, incomingIpHeader,
   550                                     incomingTcpHeader.GetSourcePort (), interface);
   565                                  << 
" data size " << packet->
GetSize ());
   575   outgoingHeader.InitializeChecksum (saddr, daddr, 
PROT_NUMBER);
   589       if (ipv4->GetRoutingProtocol () != 0)
   591           route = ipv4->GetRoutingProtocol ()->RouteOutput (packet, header, oif, errno_);
   602       NS_FATAL_ERROR (
"Trying to use Tcp on a node without an Ipv4 interface");
   616                                  << 
" data size " << packet->
GetSize ());
   643       if (ipv6->GetRoutingProtocol () != 0)
   645           route = ipv6->GetRoutingProtocol ()->RouteOutput (packet, header, oif, errno_);
   656       NS_FATAL_ERROR (
"Trying to use Tcp on a node without an Ipv6 interface");
   710   std::vector<Ptr<TcpSocketBase> >::iterator it = 
m_sockets.begin ();
   729   std::vector<Ptr<TcpSocketBase> >::iterator it = 
m_sockets.begin ();
 static bool IsMatchingType(const Address &address)
If the Address matches the type. 
TypeId m_congestionTypeId
The socket TypeId. 
void SendPacketV6(Ptr< Packet > pkt, const TcpHeader &outgoing, const Ipv6Address &saddr, const Ipv6Address &daddr, Ptr< NetDevice > oif=0) const
Send a packet via TCP (IPv6) 
std::string GetName(void) const
Get the name. 
Ptr< Socket > CreateSocket(void)
Create a TCP socket using the TypeId set by SocketType attribute. 
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Ipv4Address GetIpv4MappedAddress() const
Return the Ipv4 address. 
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...
SequenceNumber< uint32_t, int32_t > SequenceNumber32
32 bit Sequence number. 
bool IsIpv4MappedAddress() const
If the address is an IPv4-mapped address. 
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system. 
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload). 
Ipv6Address GetIpv6(void) const
Get the IPv6 address. 
virtual enum IpL4Protocol::RxStatus Receive(Ptr< Packet > p, Ipv4Header const &incomingIpHeader, Ptr< Ipv4Interface > incomingInterface)
Called from lower-level layers to send the packet up in the stack. 
std::list< Ipv6EndPoint * > EndPoints
Container of the IPv6 endpoints. 
Access to the IPv6 forwarding table, interfaces, and configuration. 
virtual void DoDispose(void)
Destructor implementation. 
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)
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together. 
Ipv6EndPoint * Allocate6(void)
Allocate an IPv6 Endpoint. 
Ptr< const AttributeAccessor > MakeObjectVectorAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector. 
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
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)
Set the TypeId of the Objects to be created by this factory. 
void SendPacketV4(Ptr< Packet > pkt, const TcpHeader &outgoing, const Ipv4Address &saddr, const Ipv4Address &daddr, Ptr< NetDevice > oif=0) const
Send a packet via TCP (IPv4) 
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO. 
enum IpL4Protocol::RxStatus PacketReceived(Ptr< Packet > packet, TcpHeader &incomingTcpHeader, const Address &source, const Address &destination)
Get the tcp header of the incoming packet and checks its checksum if needed. 
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate. 
virtual void DoDispose(void)
Destructor implementation. 
TypeId m_recoveryTypeId
The recovery TypeId. 
static TypeId GetTypeId(void)
Get the type ID. 
void AddSocket(Ptr< TcpSocketBase > socket)
Make a socket fully operational. 
SocketErrno
Enumeration of the possible errors returned by a socket. 
void DeAllocate(Ipv4EndPoint *endPoint)
Remove an IPv4 Endpoint. 
a polymophic address class 
TCP socket creation and multiplexing/demultiplexing. 
virtual void NotifyNewAggregate()
Setup socket factory and callbacks when aggregated to a node. 
Demultiplexes packets to various transport layer endpoints. 
virtual void Send(Ptr< Packet > packet, Ipv6Address source, Ipv6Address destination, uint8_t protocol, Ptr< Ipv6Route > route)=0
Higher-level layers call this method to send a packet down the stack to the MAC and PHY layers...
virtual int GetProtocolNumber(void) const
Returns the protocol number of this protocol. 
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId. 
Base class for all RTT Estimators. 
Ipv6EndPoint * Allocate(void)
Allocate a Ipv6EndPoint. 
  AttributeValue implementation for TypeId. 
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer. 
static TypeId GetTypeId(void)
Get the type ID. 
static bool IsMatchingType(const Address &address)
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC. 
std::vector< Ptr< TcpSocketBase > > m_sockets
list of sockets 
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...
void DeAllocate(Ipv6EndPoint *endPoint)
Remove a end point. 
static const uint8_t PROT_NUMBER
protocol number (0x6) 
Access to the IPv4 forwarding table, interfaces, and configuration. 
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object. 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input Address. 
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. 
Ipv6EndPoint * SimpleLookup(Ipv6Address dst, uint16_t dport, Ipv6Address src, uint16_t sport)
Simple lookup for a four-tuple match. 
Congestion control abstract class. 
Ptr< const AttributeChecker > MakeTypeIdChecker(void)
  
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. 
static TypeId GetTypeId(void)
Get the type ID. 
void NoEndPointsFound(const TcpHeader &incomingHeader, const Address &incomingSAddr, const Address &incomingDAddr)
Check if RST packet should be sent, and in case, send it. 
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)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Describes an IPv6 address. 
Instantiate subclasses of ns3::Object. 
Ptr< const AttributeAccessor > MakeTypeIdAccessor(T1 a1)
 Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
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. 
void SendPacket(Ptr< Packet > pkt, const TcpHeader &outgoing, const Address &saddr, const Address &daddr, Ptr< NetDevice > oif=0) const
Send a packet via TCP (IP-agnostic) 
Demultiplexer for end points. 
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG. 
static Inet6SocketAddress ConvertFrom(const Address &addr)
Convert the address to a InetSocketAddress. 
A representation of an IPv6 endpoint/connection. 
bool RemoveSocket(Ptr< TcpSocketBase > socket)
Remove a socket from the internal list. 
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...
static bool IsMatchingType(const Address &addr)
If the address match. 
TypeId m_rttTypeId
The RTT Estimator TypeId. 
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)
Use NS_LOG to output a message of level LOG_ERROR. 
static Ipv4Address ConvertFrom(const Address &address)
virtual void NotifyNewAggregate(void)
Notify all Objects aggregated to this one of a new Object being aggregated. 
Container for a set of ns3::Object pointers. 
void DeAllocate(Ipv4EndPoint *endPoint)
Remove a end point. 
bool IsNull(void) const
Check for null implementation. 
static Ipv6Address MakeIpv4MappedAddress(Ipv4Address addr)
Make the Ipv4-mapped IPv6 address. 
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...
a unique identifier for an interface. 
TypeId SetParent(TypeId tid)
Set the parent TypeId. 
static bool IsMatchingType(const Address &address)
IpL4Protocol::DownTargetCallback6 m_downTarget6
Callback to send packets over IPv6. 
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
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. 
Ipv4Address GetIpv4(void) const
static Ipv6Address ConvertFrom(const Address &address)
Convert the Address object into an Ipv6Address ones. 
Ipv4EndPoint * Allocate(void)
Allocate a Ipv4EndPoint.