A Discrete-Event Network Simulator
API
ns3::Ipv4EndPointDemux Class Reference

Demultiplexes packets to various transport layer endpoints. More...

#include "ipv4-end-point-demux.h"

+ Collaboration diagram for ns3::Ipv4EndPointDemux:

Public Types

typedef std::list< Ipv4EndPoint * > EndPoints
 Container of the IPv4 endpoints. More...
 
typedef std::list< Ipv4EndPoint * >::iterator EndPointsI
 Iterator to the container of the IPv4 endpoints. More...
 

Public Member Functions

 Ipv4EndPointDemux ()
 
 ~Ipv4EndPointDemux ()
 
Ipv4EndPointAllocate (Ipv4Address address)
 Allocate a Ipv4EndPoint. More...
 
Ipv4EndPointAllocate (Ptr< NetDevice > boundNetDevice, Ipv4Address address, uint16_t port)
 Allocate a Ipv4EndPoint. More...
 
Ipv4EndPointAllocate (Ptr< NetDevice > boundNetDevice, Ipv4Address localAddress, uint16_t localPort, Ipv4Address peerAddress, uint16_t peerPort)
 Allocate a Ipv4EndPoint. More...
 
Ipv4EndPointAllocate (Ptr< NetDevice > boundNetDevice, uint16_t port)
 Allocate a Ipv4EndPoint. More...
 
Ipv4EndPointAllocate (void)
 Allocate a Ipv4EndPoint. More...
 
void DeAllocate (Ipv4EndPoint *endPoint)
 Remove a end point. More...
 
EndPoints GetAllEndPoints (void)
 Get the entire list of end points registered. More...
 
EndPoints Lookup (Ipv4Address daddr, uint16_t dport, Ipv4Address saddr, uint16_t sport, Ptr< Ipv4Interface > incomingInterface)
 lookup for a match with all the parameters. More...
 
bool LookupLocal (Ptr< NetDevice > boundNetDevice, Ipv4Address addr, uint16_t port)
 Lookup for address and port. More...
 
bool LookupPortLocal (uint16_t port)
 Lookup for port local. More...
 
Ipv4EndPointSimpleLookup (Ipv4Address daddr, uint16_t dport, Ipv4Address saddr, uint16_t sport)
 simple lookup for a match with all the parameters. More...
 

Private Member Functions

uint16_t AllocateEphemeralPort (void)
 Allocate an ephemeral port. More...
 

Private Attributes

EndPoints m_endPoints
 A list of IPv4 end points. More...
 
uint16_t m_ephemeral
 The ephemeral port. More...
 
uint16_t m_portFirst
 The first ephemeral port. More...
 
uint16_t m_portLast
 The last ephemeral port. More...
 

Detailed Description

Demultiplexes packets to various transport layer endpoints.

This class serves as a lookup table to match partial or full information about a four-tuple to an ns3::Ipv4EndPoint. It internally contains a list of endpoints, and has APIs to add and find endpoints in this demux. This code is shared in common to TCP and UDP protocols in ns3. This demux sits between ns3's layer four and the socket layer

Definition at line 45 of file ipv4-end-point-demux.h.

Member Typedef Documentation

◆ EndPoints

Container of the IPv4 endpoints.

Definition at line 50 of file ipv4-end-point-demux.h.

◆ EndPointsI

Iterator to the container of the IPv4 endpoints.

Definition at line 55 of file ipv4-end-point-demux.h.

Constructor & Destructor Documentation

◆ Ipv4EndPointDemux()

ns3::Ipv4EndPointDemux::Ipv4EndPointDemux ( )

Definition at line 31 of file ipv4-end-point-demux.cc.

References NS_LOG_FUNCTION.

◆ ~Ipv4EndPointDemux()

ns3::Ipv4EndPointDemux::~Ipv4EndPointDemux ( )

Definition at line 37 of file ipv4-end-point-demux.cc.

References m_endPoints, and NS_LOG_FUNCTION.

Member Function Documentation

◆ Allocate() [1/5]

Ipv4EndPoint * ns3::Ipv4EndPointDemux::Allocate ( Ipv4Address  address)

Allocate a Ipv4EndPoint.

Parameters
addressIPv4 address
Returns
an Ipv4EndPoint instance

Definition at line 95 of file ipv4-end-point-demux.cc.

References first::address, AllocateEphemeralPort(), m_endPoints, NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_WARN, and port.

+ Here is the call graph for this function:

◆ Allocate() [2/5]

Ipv4EndPoint * ns3::Ipv4EndPointDemux::Allocate ( Ptr< NetDevice boundNetDevice,
Ipv4Address  address,
uint16_t  port 
)

Allocate a Ipv4EndPoint.

Parameters
boundNetDeviceBound NetDevice (if any)
addresslocal address
portlocal port
Returns
an Ipv4EndPoint instance

Definition at line 119 of file ipv4-end-point-demux.cc.

References first::address, LookupLocal(), m_endPoints, NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_WARN, and port.

+ Here is the call graph for this function:

◆ Allocate() [3/5]

Ipv4EndPoint * ns3::Ipv4EndPointDemux::Allocate ( Ptr< NetDevice boundNetDevice,
Ipv4Address  localAddress,
uint16_t  localPort,
Ipv4Address  peerAddress,
uint16_t  peerPort 
)

Allocate a Ipv4EndPoint.

Parameters
boundNetDeviceBound NetDevice (if any)
localAddresslocal address
localPortlocal port
peerAddresspeer address
peerPortpeer port
Returns
an Ipv4EndPoint instance

Definition at line 134 of file ipv4-end-point-demux.cc.

References m_endPoints, NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_WARN, and ns3::Ipv4EndPoint::SetPeer().

+ Here is the call graph for this function:

◆ Allocate() [4/5]

Ipv4EndPoint * ns3::Ipv4EndPointDemux::Allocate ( Ptr< NetDevice boundNetDevice,
uint16_t  port 
)

Allocate a Ipv4EndPoint.

Parameters
boundNetDeviceBound NetDevice (if any)
portlocal port
Returns
an Ipv4EndPoint instance

Definition at line 111 of file ipv4-end-point-demux.cc.

References Allocate(), ns3::Ipv4Address::GetAny(), NS_LOG_FUNCTION, and port.

+ Here is the call graph for this function:

◆ Allocate() [5/5]

Ipv4EndPoint * ns3::Ipv4EndPointDemux::Allocate ( void  )

Allocate a Ipv4EndPoint.

Returns
an empty Ipv4EndPoint instance

Definition at line 79 of file ipv4-end-point-demux.cc.

References AllocateEphemeralPort(), ns3::Ipv4Address::GetAny(), m_endPoints, NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_WARN, and port.

Referenced by Allocate(), ns3::TcpL4Protocol::Allocate(), and ns3::UdpL4Protocol::Allocate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AllocateEphemeralPort()

uint16_t ns3::Ipv4EndPointDemux::AllocateEphemeralPort ( void  )
private

Allocate an ephemeral port.

Returns
the ephemeral port

Definition at line 381 of file ipv4-end-point-demux.cc.

References LookupPortLocal(), m_ephemeral, m_portFirst, m_portLast, NS_LOG_FUNCTION, and port.

Referenced by Allocate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DeAllocate()

void ns3::Ipv4EndPointDemux::DeAllocate ( Ipv4EndPoint endPoint)

Remove a end point.

Parameters
endPointthe end point to remove

Definition at line 161 of file ipv4-end-point-demux.cc.

References m_endPoints, and NS_LOG_FUNCTION.

Referenced by ns3::TcpL4Protocol::DeAllocate(), and ns3::UdpL4Protocol::DeAllocate().

+ Here is the caller graph for this function:

◆ GetAllEndPoints()

Ipv4EndPointDemux::EndPoints ns3::Ipv4EndPointDemux::GetAllEndPoints ( void  )

Get the entire list of end points registered.

Returns
list of Ipv4EndPoint

Definition at line 179 of file ipv4-end-point-demux.cc.

References m_endPoints, and NS_LOG_FUNCTION.

◆ Lookup()

Ipv4EndPointDemux::EndPoints ns3::Ipv4EndPointDemux::Lookup ( Ipv4Address  daddr,
uint16_t  dport,
Ipv4Address  saddr,
uint16_t  sport,
Ptr< Ipv4Interface incomingInterface 
)

lookup for a match with all the parameters.

The function will return a list of most-matching EndPoints, in this order:

  1. Full match
  2. All but local address
  3. Only local port and local address match
  4. Only local port match

EndPoint with disabled Rx are skipped.

Parameters
daddrdestination address to test
dportdestination port to test
saddrsource address to test
sportsource port to test
incomingInterfacethe incoming interface
Returns
list of IPv4EndPoints (could be 0 element)

Definition at line 199 of file ipv4-end-point-demux.cc.

References ns3::Ipv4Address::CombineMask(), ns3::Ipv4Interface::GetAddress(), ns3::Ipv4Address::GetAny(), ns3::Ipv4EndPoint::GetBoundNetDevice(), ns3::Ipv4Interface::GetDevice(), ns3::Ipv4InterfaceAddress::GetLocal(), ns3::Ipv4EndPoint::GetLocalAddress(), ns3::Ipv4EndPoint::GetLocalPort(), ns3::Ipv4InterfaceAddress::GetMask(), ns3::Ipv4Interface::GetNAddresses(), ns3::Ipv4EndPoint::GetPeerAddress(), ns3::Ipv4EndPoint::GetPeerPort(), ns3::Ipv4Mask::GetPrefixLength(), ns3::Ipv4EndPoint::IsRxEnabled(), m_endPoints, NS_ABORT_MSG_IF, NS_LOG_DEBUG, NS_LOG_FUNCTION, and NS_LOG_LOGIC.

+ Here is the call graph for this function:

◆ LookupLocal()

bool ns3::Ipv4EndPointDemux::LookupLocal ( Ptr< NetDevice boundNetDevice,
Ipv4Address  addr,
uint16_t  port 
)

Lookup for address and port.

Parameters
boundNetDeviceBound NetDevice (if any)
addraddress to test
portport to test
Returns
true if there is a match in EndPoints, false otherwise

Definition at line 63 of file ipv4-end-point-demux.cc.

References m_endPoints, NS_LOG_FUNCTION, and port.

Referenced by Allocate().

+ Here is the caller graph for this function:

◆ LookupPortLocal()

bool ns3::Ipv4EndPointDemux::LookupPortLocal ( uint16_t  port)

Lookup for port local.

Parameters
portport to test
Returns
true if a port local is in EndPoints, false otherwise

Definition at line 49 of file ipv4-end-point-demux.cc.

References m_endPoints, NS_LOG_FUNCTION, and port.

Referenced by AllocateEphemeralPort().

+ Here is the caller graph for this function:

◆ SimpleLookup()

Ipv4EndPoint * ns3::Ipv4EndPointDemux::SimpleLookup ( Ipv4Address  daddr,
uint16_t  dport,
Ipv4Address  saddr,
uint16_t  sport 
)

simple lookup for a match with all the parameters.

Parameters
daddrdestination address to test
dportdestination port to test
saddrsource address to test
sportsource port to test
Returns
IPv4EndPoint (0 if not found)

Definition at line 339 of file ipv4-end-point-demux.cc.

References ns3::Ipv4Address::GetAny(), m_endPoints, and NS_LOG_FUNCTION.

Referenced by ns3::TcpL4Protocol::ReceiveIcmp(), and ns3::UdpL4Protocol::ReceiveIcmp().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_endPoints

EndPoints ns3::Ipv4EndPointDemux::m_endPoints
private

A list of IPv4 end points.

Definition at line 194 of file ipv4-end-point-demux.h.

Referenced by ~Ipv4EndPointDemux(), Allocate(), DeAllocate(), GetAllEndPoints(), Lookup(), LookupLocal(), LookupPortLocal(), and SimpleLookup().

◆ m_ephemeral

uint16_t ns3::Ipv4EndPointDemux::m_ephemeral
private

The ephemeral port.

Definition at line 179 of file ipv4-end-point-demux.h.

Referenced by AllocateEphemeralPort().

◆ m_portFirst

uint16_t ns3::Ipv4EndPointDemux::m_portFirst
private

The first ephemeral port.

Definition at line 189 of file ipv4-end-point-demux.h.

Referenced by AllocateEphemeralPort().

◆ m_portLast

uint16_t ns3::Ipv4EndPointDemux::m_portLast
private

The last ephemeral port.

Definition at line 184 of file ipv4-end-point-demux.h.

Referenced by AllocateEphemeralPort().


The documentation for this class was generated from the following files: