A representation of an internet endpoint/connection. More...
#include "ipv4-end-point.h"
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< NetDevice > | GetBoundNetDevice (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... | |
bool | IsRxEnabled (void) |
Checks if the endpoint can receive packets. 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 information (address and port). More... | |
void | SetRxCallback (Callback< void, Ptr< Packet >, Ipv4Header, uint16_t, Ptr< Ipv4Interface > > callback) |
Set the reception callback. More... | |
void | SetRxEnabled (bool enabled) |
Enable or Disable the endpoint Rx capability. More... | |
Private Attributes | |
Ptr< NetDevice > | m_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... | |
bool | m_rxEnabled |
true if the endpoint can receive packets. More... | |
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 49 of file ipv4-end-point.h.
ns3::Ipv4EndPoint::Ipv4EndPoint | ( | Ipv4Address | address, |
uint16_t | port | ||
) |
Constructor.
address | the IPv4 address |
port | the port |
Definition at line 30 of file ipv4-end-point.cc.
References first::address, NS_LOG_FUNCTION, and port.
ns3::Ipv4EndPoint::~Ipv4EndPoint | ( | ) |
Definition at line 40 of file ipv4-end-point.cc.
References ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::IsNull(), m_destroyCallback, m_icmpCallback, m_rxCallback, NS_LOG_FUNCTION, and ns3::Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::Nullify().
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.
netdevice | Pointer to Netdevice of desired interface |
Definition at line 96 of file ipv4-end-point.cc.
References m_boundnetdevice, and NS_LOG_FUNCTION.
Referenced by ns3::UdpSocketImpl::Bind(), ns3::NscTcpSocketImpl::BindToNetDevice(), ns3::UdpSocketImpl::BindToNetDevice(), and ns3::TcpSocketBase::BindToNetDevice().
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.
icmpSource | source IP address |
icmpTtl | time-to-live |
icmpType | ICMP type |
icmpCode | ICMP code |
icmpInfo | ICMP info |
Definition at line 144 of file ipv4-end-point.cc.
References m_icmpCallback, and NS_LOG_FUNCTION.
Referenced by ns3::UdpL4Protocol::ReceiveIcmp(), and ns3::TcpL4Protocol::ReceiveIcmp().
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.
p | the packet |
header | the packet header |
sport | source port |
incomingInterface | incoming interface |
Definition at line 132 of file ipv4-end-point.cc.
References m_rxCallback, and NS_LOG_FUNCTION.
Returns socket's bound netdevice, if any.
This method corresponds to using getsockopt() SO_BINDTODEVICE of real network or BSD sockets.
Definition at line 104 of file ipv4-end-point.cc.
References m_boundnetdevice, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv4EndPointDemux::Lookup().
Ipv4Address ns3::Ipv4EndPoint::GetLocalAddress | ( | void | ) |
Get the local address.
Definition at line 53 of file ipv4-end-point.cc.
References m_localAddr, and NS_LOG_FUNCTION.
Referenced by ns3::UdpSocketImpl::DoSendTo(), ns3::NscTcpSocketImpl::FinishBind(), ns3::TcpSocketBase::ForwardUp(), ns3::UdpSocketImpl::GetSockName(), ns3::TcpSocketBase::GetSockName(), ns3::Ipv4EndPointDemux::Lookup(), ns3::TcpSocketBase::PersistTimeout(), ns3::TcpSocketCongestedRouter::SendDataPacket(), ns3::TcpSocketBase::SendDataPacket(), ns3::TcpSocketSmallAcks::SendEmptyPacket(), and ns3::TcpSocketBase::SendEmptyPacket().
uint16_t ns3::Ipv4EndPoint::GetLocalPort | ( | void | ) |
Get the local port.
Definition at line 67 of file ipv4-end-point.cc.
References m_localPort, and NS_LOG_FUNCTION.
Referenced by ns3::UdpSocketImpl::DoSendTo(), ns3::NscTcpSocketImpl::FinishBind(), ns3::TcpSocketBase::ForwardUp(), ns3::UdpSocketImpl::GetSockName(), ns3::TcpSocketBase::GetSockName(), ns3::Ipv4EndPointDemux::Lookup(), ns3::TcpSocketBase::PersistTimeout(), ns3::TcpSocketCongestedRouter::SendDataPacket(), ns3::TcpSocketBase::SendDataPacket(), ns3::TcpSocketSmallAcks::SendEmptyPacket(), and ns3::TcpSocketBase::SendEmptyPacket().
Ipv4Address ns3::Ipv4EndPoint::GetPeerAddress | ( | void | ) |
Get the peer address.
Definition at line 74 of file ipv4-end-point.cc.
References m_peerAddr, and NS_LOG_FUNCTION.
Referenced by ns3::TcpSocketBase::ForwardUp(), ns3::NscTcpSocketImpl::GetPeerName(), ns3::TcpSocketBase::GetPeerName(), ns3::Ipv4EndPointDemux::Lookup(), ns3::TcpSocketBase::PersistTimeout(), ns3::TcpSocketBase::RecvFrom(), ns3::TcpSocketCongestedRouter::SendDataPacket(), ns3::TcpSocketBase::SendDataPacket(), ns3::TcpSocketSmallAcks::SendEmptyPacket(), ns3::TcpSocketBase::SendEmptyPacket(), and ns3::TcpSocketBase::SetupEndpoint().
uint16_t ns3::Ipv4EndPoint::GetPeerPort | ( | void | ) |
Get the peer port.
Definition at line 81 of file ipv4-end-point.cc.
References m_peerPort, and NS_LOG_FUNCTION.
Referenced by ns3::TcpSocketBase::ForwardUp(), ns3::NscTcpSocketImpl::GetPeerName(), ns3::TcpSocketBase::GetPeerName(), ns3::Ipv4EndPointDemux::Lookup(), ns3::TcpSocketBase::PersistTimeout(), ns3::TcpSocketBase::RecvFrom(), ns3::TcpSocketCongestedRouter::SendDataPacket(), ns3::TcpSocketBase::SendDataPacket(), ns3::TcpSocketSmallAcks::SendEmptyPacket(), and ns3::TcpSocketBase::SendEmptyPacket().
bool ns3::Ipv4EndPoint::IsRxEnabled | ( | void | ) |
Checks if the endpoint can receive packets.
Definition at line 163 of file ipv4-end-point.cc.
References m_rxEnabled.
Referenced by ns3::Ipv4EndPointDemux::Lookup().
void ns3::Ipv4EndPoint::SetDestroyCallback | ( | Callback< void > | callback | ) |
Set the default destroy callback.
callback | callback function |
Definition at line 125 of file ipv4-end-point.cc.
References m_destroyCallback, and NS_LOG_FUNCTION.
Referenced by ns3::NscTcpSocketImpl::CompleteFork(), ns3::UdpSocketImpl::DeallocateEndPoint(), ns3::TcpSocketBase::DeallocateEndPoint(), ns3::NscTcpSocketImpl::FinishBind(), ns3::UdpSocketImpl::FinishBind(), and ns3::TcpSocketBase::SetupCallback().
void ns3::Ipv4EndPoint::SetIcmpCallback | ( | Callback< void, Ipv4Address, uint8_t, uint8_t, uint8_t, uint32_t > | callback | ) |
Set the ICMP callback.
callback | callback function |
Definition at line 118 of file ipv4-end-point.cc.
References m_icmpCallback, and NS_LOG_FUNCTION.
Referenced by ns3::UdpSocketImpl::FinishBind(), and ns3::TcpSocketBase::SetupCallback().
void ns3::Ipv4EndPoint::SetLocalAddress | ( | Ipv4Address | address | ) |
Set the local address.
address | the address to set |
Definition at line 60 of file ipv4-end-point.cc.
References first::address, m_localAddr, and NS_LOG_FUNCTION.
Referenced by ns3::TcpSocketBase::SetupEndpoint().
void ns3::Ipv4EndPoint::SetPeer | ( | Ipv4Address | address, |
uint16_t | port | ||
) |
Set the peer information (address and port).
address | peer address |
port | peer port |
Definition at line 88 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().
void ns3::Ipv4EndPoint::SetRxCallback | ( | Callback< void, Ptr< Packet >, Ipv4Header, uint16_t, Ptr< Ipv4Interface > > | callback | ) |
Set the reception callback.
callback | callback function |
Definition at line 111 of file ipv4-end-point.cc.
References m_rxCallback, and NS_LOG_FUNCTION.
Referenced by ns3::NscTcpSocketImpl::CompleteFork(), ns3::NscTcpSocketImpl::FinishBind(), ns3::UdpSocketImpl::FinishBind(), and ns3::TcpSocketBase::SetupCallback().
void ns3::Ipv4EndPoint::SetRxEnabled | ( | bool | enabled | ) |
Enable or Disable the endpoint Rx capability.
enabled | true if Rx is enabled |
Definition at line 157 of file ipv4-end-point.cc.
References m_rxEnabled.
Referenced by ns3::UdpSocketImpl::ShutdownRecv().
The NetDevice the EndPoint is bound to (if any).
Definition at line 209 of file ipv4-end-point.h.
Referenced by BindToNetDevice(), and GetBoundNetDevice().
|
private |
The destroy callback.
Definition at line 224 of file ipv4-end-point.h.
Referenced by SetDestroyCallback(), and ~Ipv4EndPoint().
|
private |
The ICMPv6 callback.
Definition at line 219 of file ipv4-end-point.h.
Referenced by ForwardIcmp(), SetIcmpCallback(), and ~Ipv4EndPoint().
|
private |
The local address.
Definition at line 189 of file ipv4-end-point.h.
Referenced by GetLocalAddress(), and SetLocalAddress().
|
private |
|
private |
The peer address.
Definition at line 199 of file ipv4-end-point.h.
Referenced by GetPeerAddress(), and SetPeer().
|
private |
The peer port.
Definition at line 204 of file ipv4-end-point.h.
Referenced by GetPeerPort(), and SetPeer().
|
private |
The RX callback.
Definition at line 214 of file ipv4-end-point.h.
Referenced by ForwardUp(), SetRxCallback(), and ~Ipv4EndPoint().
|
private |
true if the endpoint can receive packets.
Definition at line 229 of file ipv4-end-point.h.
Referenced by IsRxEnabled(), and SetRxEnabled().