A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ns3::Ipv4EndPoint Class Reference

A representation of an internet endpoint/connection. More...

#include <ipv4-end-point.h>

+ Collaboration diagram for ns3::Ipv4EndPoint:

Public Member Functions

 Ipv4EndPoint (Ipv4Address address, uint16_t port)
 Constructor. More...
 
 ~Ipv4EndPoint ()
 
void BindToNetDevice (Ptr< NetDevice > netdevice)
 Bind a socket to specific device. More...
 
void ForwardIcmp (Ipv4Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo)
 Forward the ICMP packet to the upper level. More...
 
void ForwardUp (Ptr< Packet > p, const Ipv4Header &header, uint16_t sport, Ptr< Ipv4Interface > incomingInterface)
 Forward the packet to the upper level. More...
 
Ptr< NetDeviceGetBoundNetDevice (void)
 Returns socket's bound netdevice, if any. More...
 
Ipv4Address GetLocalAddress (void)
 Get the local address. More...
 
uint16_t GetLocalPort (void)
 Get the local port. More...
 
Ipv4Address GetPeerAddress (void)
 Get the peer address. More...
 
uint16_t GetPeerPort (void)
 Get the peer port. More...
 
void SetDestroyCallback (Callback< void > callback)
 Set the default destroy callback. More...
 
void SetIcmpCallback (Callback< void, Ipv4Address, uint8_t, uint8_t, uint8_t, uint32_t > callback)
 Set the ICMP callback. More...
 
void SetLocalAddress (Ipv4Address address)
 Set the local address. More...
 
void SetPeer (Ipv4Address address, uint16_t port)
 Set the peer informations (address and port). More...
 
void SetRxCallback (Callback< void, Ptr< Packet >, Ipv4Header, uint16_t, Ptr< Ipv4Interface > > callback)
 Set the reception callback. More...
 

Private Member Functions

void DoForwardIcmp (Ipv4Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo)
 ForwardIcmp wrapper. More...
 
void DoForwardUp (Ptr< Packet > p, const Ipv4Header &header, uint16_t sport, Ptr< Ipv4Interface > incomingInterface)
 ForwardUp wrapper. More...
 

Private Attributes

Ptr< NetDevicem_boundnetdevice
 The NetDevice the EndPoint is bound to (if any). More...
 
Callback< void > m_destroyCallback
 The destroy callback. More...
 
Callback< void, Ipv4Address,
uint8_t, uint8_t, uint8_t,
uint32_t > 
m_icmpCallback
 The ICMPv6 callback. More...
 
Ipv4Address m_localAddr
 The local address. More...
 
uint16_t m_localPort
 The local port. More...
 
Ipv4Address m_peerAddr
 The peer address. More...
 
uint16_t m_peerPort
 The peer port. More...
 
Callback< void, Ptr< Packet >
, Ipv4Header, uint16_t, Ptr
< Ipv4Interface > > 
m_rxCallback
 The RX callback. More...
 

Detailed Description

A representation of an internet endpoint/connection.

This class provides an internet four-tuple (source and destination ports and addresses). These are used in the ns3::Ipv4EndPointDemux as targets of lookups. The class also has a callback for notification to higher layers that a packet from a lower layer was received. In the ns3 internet-stack, these notifications are automatically registered to be received by the corresponding socket.

Definition at line 47 of file ipv4-end-point.h.

Constructor & Destructor Documentation

ns3::Ipv4EndPoint::Ipv4EndPoint ( Ipv4Address  address,
uint16_t  port 
)

Constructor.

Parameters
addressthe IPv4 address
portthe port

Definition at line 30 of file ipv4-end-point.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

void ns3::Ipv4EndPoint::BindToNetDevice ( Ptr< NetDevice netdevice)

Bind a socket to specific device.

This method corresponds to using setsockopt() SO_BINDTODEVICE of real network or BSD sockets. If set on a socket, this option will force packets to leave the bound device regardless of the device that IP routing would naturally choose. In the receive direction, only packets received from the bound interface will be delivered.

This option has no particular relationship to binding sockets to an address via Socket::Bind (). It is possible to bind sockets to a specific IP address on the bound interface by calling both Socket::Bind (address) and Socket::BindToNetDevice (device), but it is also possible to bind to mismatching device and address, even if the socket can not receive any packets as a result.

Parameters
netdevicePointer to Netdevice of desired interface

Definition at line 91 of file ipv4-end-point.cc.

References m_boundnetdevice, and NS_LOG_FUNCTION.

Referenced by ns3::UdpSocketImpl::BindToNetDevice(), and ns3::TcpSocketBase::BindToNetDevice().

+ Here is the caller graph for this function:

void ns3::Ipv4EndPoint::DoForwardIcmp ( Ipv4Address  icmpSource,
uint8_t  icmpTtl,
uint8_t  icmpType,
uint8_t  icmpCode,
uint32_t  icmpInfo 
)
private

ForwardIcmp wrapper.

Parameters
icmpSourcesource IP address
icmpTtltime-to-live
icmpTypeICMP type
icmpCodeICMP code
icmpInfoICMP info

Definition at line 163 of file ipv4-end-point.cc.

References m_icmpCallback, and NS_LOG_FUNCTION.

Referenced by ForwardIcmp().

+ Here is the caller graph for this function:

void ns3::Ipv4EndPoint::DoForwardUp ( Ptr< Packet p,
const Ipv4Header header,
uint16_t  sport,
Ptr< Ipv4Interface incomingInterface 
)
private

ForwardUp wrapper.

Parameters
ppacket
headerthe packet header
sportsource port
incomingInterfaceincoming interface

Definition at line 138 of file ipv4-end-point.cc.

References m_rxCallback, and NS_LOG_FUNCTION.

Referenced by ForwardUp().

+ Here is the caller graph for this function:

void ns3::Ipv4EndPoint::ForwardIcmp ( Ipv4Address  icmpSource,
uint8_t  icmpTtl,
uint8_t  icmpType,
uint8_t  icmpCode,
uint32_t  icmpInfo 
)

Forward the ICMP packet to the upper level.

Called from an L4Protocol implementation to notify an endpoint of an icmp message reception.

Parameters
icmpSourcesource IP address
icmpTtltime-to-live
icmpTypeICMP type
icmpCodeICMP code
icmpInfoICMP info

Definition at line 150 of file ipv4-end-point.cc.

References DoForwardIcmp(), m_icmpCallback, NS_LOG_FUNCTION, and ns3::Simulator::ScheduleNow().

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:

void ns3::Ipv4EndPoint::ForwardUp ( Ptr< Packet p,
const Ipv4Header header,
uint16_t  sport,
Ptr< Ipv4Interface incomingInterface 
)

Forward the packet to the upper level.

Called from an L4Protocol implementation to notify an endpoint of a packet reception.

Parameters
pthe packet
headerthe packet header
sportsource port
incomingInterfaceincoming interface

Definition at line 126 of file ipv4-end-point.cc.

References DoForwardUp(), m_rxCallback, NS_LOG_FUNCTION, and ns3::Simulator::ScheduleNow().

+ Here is the call graph for this function:

Ptr< NetDevice > ns3::Ipv4EndPoint::GetBoundNetDevice ( void  )

Returns socket's bound netdevice, if any.

This method corresponds to using getsockopt() SO_BINDTODEVICE of real network or BSD sockets.

Returns
Pointer to interface.

Definition at line 99 of file ipv4-end-point.cc.

References m_boundnetdevice, and NS_LOG_FUNCTION.

Referenced by ns3::Ipv4EndPointDemux::Lookup().

+ Here is the caller graph for this function:

Ipv4Address ns3::Ipv4EndPoint::GetPeerAddress ( void  )
uint16_t ns3::Ipv4EndPoint::GetPeerPort ( void  )
void ns3::Ipv4EndPoint::SetDestroyCallback ( Callback< void >  callback)

Set the default destroy callback.

Parameters
callbackcallback function

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

References m_destroyCallback, and NS_LOG_FUNCTION.

Referenced by ns3::NscTcpSocketImpl::CompleteFork(), ns3::TcpSocketBase::DeallocateEndPoint(), ns3::NscTcpSocketImpl::FinishBind(), ns3::UdpSocketImpl::FinishBind(), and ns3::TcpSocketBase::SetupCallback().

+ Here is the caller graph for this function:

void ns3::Ipv4EndPoint::SetIcmpCallback ( Callback< void, Ipv4Address, uint8_t, uint8_t, uint8_t, uint32_t >  callback)

Set the ICMP callback.

Parameters
callbackcallback function

Definition at line 112 of file ipv4-end-point.cc.

References m_icmpCallback, and NS_LOG_FUNCTION.

Referenced by ns3::UdpSocketImpl::FinishBind(), and ns3::TcpSocketBase::SetupCallback().

+ Here is the caller graph for this function:

void ns3::Ipv4EndPoint::SetLocalAddress ( Ipv4Address  address)

Set the local address.

Parameters
addressthe address to set

Definition at line 58 of file ipv4-end-point.cc.

References first::address, m_localAddr, and NS_LOG_FUNCTION.

Referenced by ns3::TcpSocketBase::SetupEndpoint().

+ Here is the caller graph for this function:

void ns3::Ipv4EndPoint::SetPeer ( Ipv4Address  address,
uint16_t  port 
)

Set the peer informations (address and port).

Parameters
addresspeer address
portpeer port

Definition at line 83 of file ipv4-end-point.cc.

References first::address, m_peerAddr, m_peerPort, NS_LOG_FUNCTION, and port.

Referenced by ns3::Ipv4EndPointDemux::Allocate(), ns3::TcpSocketBase::Connect(), and ns3::TcpSocketBase::ProcessSynRcvd().

+ Here is the caller graph for this function:

void ns3::Ipv4EndPoint::SetRxCallback ( Callback< void, Ptr< Packet >, Ipv4Header, uint16_t, Ptr< Ipv4Interface > >  callback)

Set the reception callback.

Parameters
callbackcallback function

Definition at line 106 of file ipv4-end-point.cc.

References m_rxCallback, and NS_LOG_FUNCTION.

Referenced by ns3::NscTcpSocketImpl::CompleteFork(), ns3::UdpSocketImpl::FinishBind(), ns3::NscTcpSocketImpl::FinishBind(), and ns3::TcpSocketBase::SetupCallback().

+ Here is the caller graph for this function:

Member Data Documentation

Ptr<NetDevice> ns3::Ipv4EndPoint::m_boundnetdevice
private

The NetDevice the EndPoint is bound to (if any).

Definition at line 216 of file ipv4-end-point.h.

Referenced by BindToNetDevice(), and GetBoundNetDevice().

Callback<void> ns3::Ipv4EndPoint::m_destroyCallback
private

The destroy callback.

Definition at line 231 of file ipv4-end-point.h.

Referenced by SetDestroyCallback(), and ~Ipv4EndPoint().

Callback<void,Ipv4Address,uint8_t,uint8_t,uint8_t,uint32_t> ns3::Ipv4EndPoint::m_icmpCallback
private

The ICMPv6 callback.

Definition at line 226 of file ipv4-end-point.h.

Referenced by DoForwardIcmp(), ForwardIcmp(), SetIcmpCallback(), and ~Ipv4EndPoint().

Ipv4Address ns3::Ipv4EndPoint::m_localAddr
private

The local address.

Definition at line 196 of file ipv4-end-point.h.

Referenced by GetLocalAddress(), and SetLocalAddress().

uint16_t ns3::Ipv4EndPoint::m_localPort
private

The local port.

Definition at line 201 of file ipv4-end-point.h.

Referenced by GetLocalPort().

Ipv4Address ns3::Ipv4EndPoint::m_peerAddr
private

The peer address.

Definition at line 206 of file ipv4-end-point.h.

Referenced by GetPeerAddress(), and SetPeer().

uint16_t ns3::Ipv4EndPoint::m_peerPort
private

The peer port.

Definition at line 211 of file ipv4-end-point.h.

Referenced by GetPeerPort(), and SetPeer().

Callback<void,Ptr<Packet>, Ipv4Header, uint16_t, Ptr<Ipv4Interface> > ns3::Ipv4EndPoint::m_rxCallback
private

The RX callback.

Definition at line 221 of file ipv4-end-point.h.

Referenced by DoForwardUp(), ForwardUp(), SetRxCallback(), and ~Ipv4EndPoint().


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