A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ns3::UdpSocket Class Referenceabstract

(abstract) base class of all UdpSockets More...

#include <udp-socket.h>

+ Inheritance diagram for ns3::UdpSocket:

Public Member Functions

virtual int MulticastJoinGroup (uint32_t interface, const Address &groupAddress)=0
 Corresponds to socket option MCAST_JOIN_GROUP. More...
 
virtual int MulticastLeaveGroup (uint32_t interface, const Address &groupAddress)=0
 Corresponds to socket option MCAST_LEAVE_GROUP. More...
 
- Public Member Functions inherited from ns3::Socket
virtual int Bind (const Address &address)=0
 Allocate a local endpoint for this socket. More...
 
virtual int Bind ()=0
 Allocate a local IPv4 endpoint for this socket. More...
 
virtual int Bind6 ()=0
 Allocate a local IPv6 endpoint for this socket. More...
 
virtual void BindToNetDevice (Ptr< NetDevice > netdevice)
 Bind a socket to specific device. More...
 
virtual int Close (void)=0
 Close a socket. More...
 
virtual int Connect (const Address &address)=0
 Initiate a connection to a remote host. More...
 
virtual bool GetAllowBroadcast () const =0
 Query whether broadcast datagram transmissions are allowed. More...
 
Ptr< NetDeviceGetBoundNetDevice ()
 Returns socket's bound netdevice, if any. More...
 
virtual enum Socket::SocketErrno GetErrno (void) const =0
 
uint8_t GetIpTos (void) const
 
virtual uint8_t GetIpTtl (void) const
 
virtual uint8_t GetIpv6HopLimit (void) const
 
uint8_t GetIpv6Tclass (void) const
 
virtual Ptr< NodeGetNode (void) const =0
 
virtual uint32_t GetRxAvailable (void) const =0
 
virtual enum Socket::SocketType GetSocketType (void) const =0
 
virtual int GetSockName (Address &address) const =0
 
virtual uint32_t GetTxAvailable (void) const =0
 Returns the number of bytes which can be sent in a single call to Send. More...
 
bool IsIpRecvTos (void) const
 Ask if the socket is currently passing information about IP Type of Service up the stack. More...
 
bool IsIpRecvTtl (void) const
 Ask if the socket is currently passing information about IP_TTL up the stack. More...
 
bool IsIpv6RecvHopLimit (void) const
 Ask if the socket is currently passing information about IPv6 Hop Limit up the stack. More...
 
bool IsIpv6RecvTclass (void) const
 Ask if the socket is currently passing information about IPv6 Traffic Class up the stack. More...
 
bool IsRecvPktInfo () const
 Get status indicating whether enable/disable packet information to socket. More...
 
virtual int Listen (void)=0
 Listen for incoming connections. More...
 
virtual Ptr< PacketRecv (uint32_t maxSize, uint32_t flags)=0
 Read data from the socket. More...
 
Ptr< PacketRecv (void)
 Read a single packet from the socket. More...
 
int Recv (uint8_t *buf, uint32_t size, uint32_t flags)
 Recv data (or dummy data) from the remote host. More...
 
virtual Ptr< PacketRecvFrom (uint32_t maxSize, uint32_t flags, Address &fromAddress)=0
 Read a single packet from the socket and retrieve the sender address. More...
 
Ptr< PacketRecvFrom (Address &fromAddress)
 Read a single packet from the socket and retrieve the sender address. More...
 
int RecvFrom (uint8_t *buf, uint32_t size, uint32_t flags, Address &fromAddress)
 Read a single packet from the socket and retrieve the sender address. More...
 
virtual int Send (Ptr< Packet > p, uint32_t flags)=0
 Send data (or dummy data) to the remote host. More...
 
int Send (Ptr< Packet > p)
 Send data (or dummy data) to the remote host. More...
 
int Send (const uint8_t *buf, uint32_t size, uint32_t flags)
 Send data (or dummy data) to the remote host. More...
 
virtual int SendTo (Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
 Send data to a specified peer. More...
 
int SendTo (const uint8_t *buf, uint32_t size, uint32_t flags, const Address &address)
 Send data to a specified peer. More...
 
void SetAcceptCallback (Callback< bool, Ptr< Socket >, const Address & > connectionRequest, Callback< void, Ptr< Socket >, const Address & > newConnectionCreated)
 Accept connection requests from remote hosts. More...
 
virtual bool SetAllowBroadcast (bool allowBroadcast)=0
 Configure whether broadcast datagram transmissions are allowed. More...
 
void SetCloseCallbacks (Callback< void, Ptr< Socket > > normalClose, Callback< void, Ptr< Socket > > errorClose)
 Detect socket recv() events such as graceful shutdown or error. More...
 
void SetConnectCallback (Callback< void, Ptr< Socket > > connectionSucceeded, Callback< void, Ptr< Socket > > connectionFailed)
 Specify callbacks to allow the caller to determine if the connection succeeds of fails. More...
 
void SetDataSentCallback (Callback< void, Ptr< Socket >, uint32_t > dataSent)
 Notify application when a packet has been sent from transport protocol (non-standard socket call) More...
 
void SetIpRecvTos (bool ipv4RecvTos)
 Tells a socket to pass information about IP Type of Service up the stack. More...
 
void SetIpRecvTtl (bool ipv4RecvTtl)
 Tells a socket to pass information about IP_TTL up the stack. More...
 
void SetIpTos (uint8_t ipTos)
 
virtual void SetIpTtl (uint8_t ipTtl)
 
virtual void SetIpv6HopLimit (uint8_t ipHopLimit)
 
void SetIpv6RecvHopLimit (bool ipv6RecvHopLimit)
 Tells a socket to pass information about IPv6 Hop Limit up the stack. More...
 
void SetIpv6RecvTclass (bool ipv6RecvTclass)
 Tells a socket to pass information about IPv6 Traffic Class up the stack. More...
 
void SetIpv6Tclass (int ipTclass)
 
void SetRecvCallback (Callback< void, Ptr< Socket > >)
 Notify application when new data is available to be read. More...
 
void SetRecvPktInfo (bool flag)
 Enable/Disable receive packet information to socket. More...
 
void SetSendCallback (Callback< void, Ptr< Socket >, uint32_t > sendCb)
 Notify application when space in transmit buffer is added. More...
 
virtual int ShutdownRecv (void)=0
 
virtual int ShutdownSend (void)=0
 
- Public Member Functions inherited from ns3::Object
void AggregateObject (Ptr< Object > other)
 
void Dispose (void)
 
AggregateIterator GetAggregateIterator (void) const
 
virtual TypeId GetInstanceTypeId (void) const
 
template<typename T >
Ptr< T > GetObject (void) const
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 
void Initialize (void)
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount (const SimpleRefCount &o)
 
uint32_t GetReferenceCount (void) const
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 
void Ref (void) const
 
void Unref (void) const
 
- Public Member Functions inherited from ns3::ObjectBase
void GetAttribute (std::string name, AttributeValue &value) const
 
bool GetAttributeFailSafe (std::string name, AttributeValue &attribute) const
 
void SetAttribute (std::string name, const AttributeValue &value)
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 

Static Public Member Functions

static TypeId GetTypeId (void)
 
- Static Public Member Functions inherited from ns3::Socket
static Ptr< SocketCreateSocket (Ptr< Node > node, TypeId tid)
 
static TypeId GetTypeId (void)
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId (void)
 
- Static Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
static void Cleanup (void)
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId (void)
 

Private Member Functions

virtual int32_t GetIpMulticastIf (void) const =0
 
virtual bool GetIpMulticastLoop (void) const =0
 
virtual uint8_t GetIpMulticastTtl (void) const =0
 
virtual bool GetMtuDiscover (void) const =0
 
virtual uint32_t GetRcvBufSize (void) const =0
 
virtual void SetIpMulticastIf (int32_t ipIf)=0
 
virtual void SetIpMulticastLoop (bool loop)=0
 
virtual void SetIpMulticastTtl (uint8_t ipTtl)=0
 
virtual void SetMtuDiscover (bool discover)=0
 
virtual void SetRcvBufSize (uint32_t size)=0
 

Additional Inherited Members

- Public Types inherited from ns3::Socket
enum  SocketErrno {
  ERROR_NOTERROR, ERROR_ISCONN, ERROR_NOTCONN, ERROR_MSGSIZE,
  ERROR_AGAIN, ERROR_SHUTDOWN, ERROR_OPNOTSUPP, ERROR_AFNOSUPPORT,
  ERROR_INVAL, ERROR_BADF, ERROR_NOROUTETOHOST, ERROR_NODEV,
  ERROR_ADDRNOTAVAIL, ERROR_ADDRINUSE, SOCKET_ERRNO_LAST
}
 
enum  SocketType { NS3_SOCK_STREAM, NS3_SOCK_SEQPACKET, NS3_SOCK_DGRAM, NS3_SOCK_RAW }
 
- Protected Member Functions inherited from ns3::Socket
virtual void DoDispose (void)
 
bool IsManualIpTos (void) const
 
bool IsManualIpTtl (void) const
 
bool IsManualIpv6HopLimit (void) const
 
bool IsManualIpv6Tclass (void) const
 
void NotifyConnectionFailed (void)
 
bool NotifyConnectionRequest (const Address &from)
 
void NotifyConnectionSucceeded (void)
 
void NotifyDataRecv (void)
 
void NotifyDataSent (uint32_t size)
 
void NotifyErrorClose (void)
 
void NotifyNewConnectionCreated (Ptr< Socket > socket, const Address &from)
 
void NotifyNormalClose (void)
 
void NotifySend (uint32_t spaceAvailable)
 
- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 
virtual void DoInitialize (void)
 
virtual void NotifyNewAggregate (void)
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 
virtual void NotifyConstructionCompleted (void)
 
- Protected Attributes inherited from ns3::Socket
Ptr< NetDevicem_boundnetdevice
 
bool m_recvPktInfo
 

Detailed Description

(abstract) base class of all UdpSockets

This class exists solely for hosting UdpSocket attributes that can be reused across different implementations, and for declaring UDP-specific multicast API.

Doxygen introspection did not find any typical Config paths.

Attributes

  • RcvBufSize: UdpSocket maximum receive buffer size (bytes)
  • IpTtl: socket-specific TTL for unicast IP packets (if non-zero)
  • IpMulticastTtl: socket-specific TTL for multicast IP packets (if non-zero)
  • IpMulticastIf: interface index for outgoing multicast on this socket; -1 indicates to use default interface
    • Set with class: ns3::IntegerValue
    • Underlying type: int32_t -2147483648:2147483647
    • Initial value: -1
    • Flags: construct write read
  • IpMulticastLoop: whether outgoing multicast sent also to loopback interface
    • Set with class: BooleanValue
    • Underlying type: bool
    • Initial value: false
    • Flags: construct write read
  • MtuDiscover: If enabled, every outgoing ip packet will have the DF flag set.
    • Set with class: BooleanValue
    • Underlying type: bool
    • Initial value: false
    • Flags: construct write read

No TraceSources are defined for this type.

Definition at line 46 of file udp-socket.h.

Member Function Documentation

virtual int ns3::UdpSocket::MulticastJoinGroup ( uint32_t  interface,
const Address groupAddress 
)
pure virtual

Corresponds to socket option MCAST_JOIN_GROUP.

Parameters
interfaceinterface number, or 0
groupAddressmulticast group address
Returns
on success, zero is returned. On error, -1 is returned, and errno is set appropriately

Enable reception of multicast datagrams for this socket on the interface number specified. If zero is specified as the interface, then a single local interface is chosen by system. In the future, this function will generate trigger IGMP joins as necessary when IGMP is implemented, but for now, this just enables multicast datagram reception in the system if not already enabled for this interface/groupAddress combination.

Attention
IGMP is not yet implemented in ns-3

This function may be called repeatedly on a given socket but each join must be for a different multicast address, or for the same multicast address but on a different interface from previous joins. This enables host multihoming, and the ability to join the same group on different interfaces.

Implemented in ns3::UdpSocketImpl.

virtual int ns3::UdpSocket::MulticastLeaveGroup ( uint32_t  interface,
const Address groupAddress 
)
pure virtual

Corresponds to socket option MCAST_LEAVE_GROUP.

Parameters
interfaceinterface number, or 0
groupAddressmulticast group address
Returns
on success, zero is returned. On error, -1 is returned, and errno is set appropriately

Disable reception of multicast datagrams for this socket on the interface number specified. If zero is specified as the interfaceIndex, then a single local interface is chosen by system. In the future, this function will generate trigger IGMP leaves as necessary when IGMP is implemented, but for now, this just disables multicast datagram reception in the system if this socket is the last for this interface/groupAddress combination.

Attention
IGMP is not yet implemented in ns-3

Implemented in ns3::UdpSocketImpl.


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