|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
26 #include "ns3/callback.h"
29 #include "ns3/object.h"
30 #include "ns3/net-device.h"
33 #include "ns3/inet-socket-address.h"
34 #include "ns3/inet6-socket-address.h"
220 const Address &> connectionRequest,
222 const Address&> newConnectionCreated);
509 int Send (
const uint8_t* buf, uint32_t size, uint32_t flags);
528 int SendTo (
const uint8_t* buf, uint32_t size, uint32_t flags,
556 int Recv (uint8_t* buf, uint32_t size, uint32_t flags);
590 int RecvFrom (uint8_t* buf, uint32_t size, uint32_t flags,
881 virtual void SetIpTtl (uint8_t ipTtl);
891 virtual uint8_t
GetIpTtl (
void)
const;
1126 void SetTtl (uint8_t ttl);
1133 uint8_t
GetTtl (
void)
const;
1154 virtual void Print (std::ostream &os)
const;
1202 virtual void Print (std::ostream &os)
const;
1253 virtual void Print (std::ostream &os)
const;
1272 void SetTos (uint8_t tos);
1279 uint8_t
GetTos (
void)
const;
1300 virtual void Print (std::ostream &os)
const;
1346 virtual void Print (std::ostream &os)
const;
1393 virtual void Print (std::ostream &os)
const;
a unique identifier for an interface.
void NotifyConnectionSucceeded(void)
Notify through the callback (if set) that the connection has been established.
virtual bool SetAllowBroadcast(bool allowBroadcast)=0
Configure whether broadcast datagram transmissions are allowed.
uint8_t m_hopLimit
the Hop Limit carried by the tag
void SetIpTos(uint8_t ipTos)
Manually set IP Type of Service field.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
void SetDataSentCallback(Callback< void, Ptr< Socket >, uint32_t > dataSent)
Notify application when a packet has been sent from transport protocol (non-standard socket call)
bool IsIpRecvTtl(void) const
Ask if the socket is currently passing information about IP_TTL up the stack.
virtual void Deserialize(TagBuffer i)
bool m_manualIpv6HopLimit
socket has IPv6 Hop Limit set
SocketErrno
Enumeration of the possible errors returned by a socket.
void SetCloseCallbacks(Callback< void, Ptr< Socket > > normalClose, Callback< void, Ptr< Socket > > errorClose)
Detect socket recv() events such as graceful shutdown or error.
Callback< void, Ptr< Socket > > m_connectionFailed
connection failed callback
bool m_dontFragment
DF bit value for outgoing packets.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< Packet > Recv(void)
Read a single packet from the socket.
virtual void Print(std::ostream &os) const
virtual enum Socket::SocketType GetSocketType(void) const =0
void SetIpv6RecvTclass(bool ipv6RecvTclass)
Tells a socket to pass information about IPv6 Traffic Class up the stack.
virtual void Deserialize(TagBuffer i)
uint8_t GetTos(void) const
Get the tag's TOS.
void SetRecvPktInfo(bool flag)
Enable/Disable receive packet information to socket.
virtual Ptr< Node > GetNode(void) const =0
Return the node this socket is associated with.
@ NS3_PRIO_INTERACTIVE_BULK
Callback< void, Ptr< Socket >, uint32_t > m_sendCb
packet sent callback
virtual void Deserialize(TagBuffer i)
void SetAcceptCallback(Callback< bool, Ptr< Socket >, const Address & > connectionRequest, Callback< void, Ptr< Socket >, const Address & > newConnectionCreated)
Accept connection requests from remote hosts.
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.
Describes an IPv6 address.
virtual void Serialize(TagBuffer i) const
virtual int Bind6()=0
Allocate a local IPv6 endpoint for this socket.
bool IsIpv6RecvHopLimit(void) const
Ask if the socket is currently passing information about IPv6 Hop Limit up the stack.
virtual uint32_t GetSerializedSize(void) const
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
void NotifyNormalClose(void)
Notify through the callback (if set) that the connection has been closed.
bool NotifyConnectionRequest(const Address &from)
Notify through the callback (if set) that an incoming connection is being requested by a remote host.
void SetTtl(uint8_t ttl)
Set the tag's TTL.
bool m_ipv6RecvHopLimit
socket forwards IPv6 Hop Limit tag to L4
void SetSendCallback(Callback< void, Ptr< Socket >, uint32_t > sendCb)
Notify application when space in transmit buffer is added.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
bool IsIpv6RecvTclass(void) const
Ask if the socket is currently passing information about IPv6 Traffic Class up the stack.
uint8_t m_priority
the socket priority
virtual uint8_t GetIpTtl(void) const
Query the value of IP Time to Live field of this socket.
bool m_ipRecvTtl
socket forwards IPv4 TTL tag to L4
Ipv6MulticastFilterMode
Enumeration of the possible filter of a socket.
static TypeId GetTypeId(void)
Get the type ID.
Callback< void, Ptr< Socket >, const Address & > m_newConnectionCreated
connection created callback
virtual void Serialize(TagBuffer i) const
uint8_t GetTclass(void) const
Get the tag's Tclass.
uint8_t m_ttl
the ttl carried by the tag
virtual uint8_t GetIpv6HopLimit(void) const
Query the value of IP Hop Limit field of this socket.
void SetPriority(uint8_t priority)
Set the tag's priority.
virtual void SetIpTtl(uint8_t ipTtl)
Manually set IP Time to Live field.
uint8_t GetHopLimit(void) const
Get the tag's Hop Limit.
virtual int Send(Ptr< Packet > p, uint32_t flags)=0
Send data (or dummy data) to the remote host.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
void Enable(void)
Enables the DF (Don't Fragment) flag.
virtual void Print(std::ostream &os) const
Callback< void, Ptr< Socket > > m_receivedData
data received callback
A low-level Socket API based loosely on the BSD Socket API.
tag a set of bytes in a packet
a polymophic address class
uint8_t GetPriority(void) const
Get the tag's priority.
A base class which provides memory management and object aggregation.
static TypeId GetTypeId(void)
Get the type ID.
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)=0
Read a single packet from the socket and retrieve the sender address.
virtual void Serialize(TagBuffer i) const
bool m_ipv6RecvTclass
socket forwards IPv6 Tclass tag to L4
virtual int Bind()=0
Allocate a local IPv4 endpoint for this socket.
This class implements a tag that carries the socket-specific HOPLIMIT of a packet to the IPv6 layer.
SocketSetDontFragmentTag()
virtual void Print(std::ostream &os) const
SocketPriority
Enumeration of the possible socket priorities.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
void NotifyConnectionFailed(void)
Notify through the callback (if set) that the connection has not been established due to an error.
SocketType
Enumeration of the possible socket types.
virtual uint32_t GetSerializedSize(void) const
virtual uint32_t GetSerializedSize(void) const
static TypeId GetTypeId(void)
Get the type ID.
Ptr< NetDevice > GetBoundNetDevice()
Returns socket's bound NetDevice, if any.
virtual void Deserialize(TagBuffer i)
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
virtual void Print(std::ostream &os) const
bool IsManualIpv6HopLimit(void) const
Checks if the socket has a specific IPv6 Hop Limit set.
indicates whether the socket has IPV6_TCLASS set.
virtual void Deserialize(TagBuffer i)
virtual int Close(void)=0
Close a socket.
virtual void Ipv6JoinGroup(Ipv6Address address, Ipv6MulticastFilterMode filterMode, std::vector< Ipv6Address > sourceAddresses)
Joins a IPv6 multicast group.
Callback< void, Ptr< Socket > > m_normalClose
connection closed callback
virtual bool GetAllowBroadcast() const =0
Query whether broadcast datagram transmissions are allowed.
Callback< void, Ptr< Socket >, uint32_t > m_dataSent
data sent callback
virtual int ShutdownSend(void)=0
virtual void Ipv6LeaveGroup(void)
Leaves IPv6 multicast group this socket is joined to.
Callback< void, Ptr< Socket > > m_connectionSucceeded
connection succeeded callback
void SetIpRecvTos(bool ipv4RecvTos)
Tells a socket to pass information about IP Type of Service up the stack.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
virtual uint32_t GetTxAvailable(void) const =0
Returns the number of bytes which can be sent in a single call to Send.
bool m_ipRecvTos
socket forwards IPv4 TOS tag to L4
Callback< bool, Ptr< Socket >, const Address & > m_connectionRequest
connection request callback
virtual int GetPeerName(Address &address) const =0
Get the peer address of a connected socket.
void SetIpv6RecvHopLimit(bool ipv6RecvHopLimit)
Tells a socket to pass information about IPv6 Hop Limit up the stack.
uint8_t GetTtl(void) const
Get the tag's TTL.
virtual void Serialize(TagBuffer i) const
static TypeId GetTypeId(void)
Get the type ID.
virtual void Serialize(TagBuffer i) const
virtual void Print(std::ostream &os) const
virtual int Listen(void)=0
Listen for incoming connections.
indicates whether the socket has a priority set.
bool IsManualIpv6Tclass(void) const
Checks if the socket has a specific IPv6 Tclass set.
void NotifyDataRecv(void)
Notify through the callback (if set) that some data have been received.
bool m_manualIpv6Tclass
socket has IPv6 Tclass set
void SetTclass(uint8_t tclass)
Set the tag's Tclass.
virtual enum Socket::SocketErrno GetErrno(void) const =0
Get last error number.
indicates whether the socket has IP_TOS set.
virtual void Serialize(TagBuffer i) const
void SetTos(uint8_t tos)
Set the tag's TOS.
uint8_t m_ipTtl
the socket IPv4 TTL
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
static TypeId GetTypeId(void)
Get the type ID.
uint8_t m_ipv6Tclass
the socket IPv6 Tclass
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer.
virtual uint32_t GetSerializedSize(void) const
void SetIpv6Tclass(int ipTclass)
Manually set IPv6 Traffic Class field.
Callback< void, Ptr< Socket > > m_errorClose
connection closed due to errors callback
uint8_t m_priority
the priority carried by the tag
uint8_t GetPriority(void) const
Query the priority value of this socket.
void SetIpRecvTtl(bool ipv4RecvTtl)
Tells a socket to pass information about IP_TTL up the stack.
virtual void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
virtual void DoDispose(void)
Destructor implementation.
virtual void Print(std::ostream &os) const
virtual void SetIpv6HopLimit(uint8_t ipHopLimit)
Manually set IPv6 Hop Limit.
void Disable(void)
Disables the DF (Don't Fragment) flag.
static TypeId GetTypeId(void)
Get the type ID.
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
uint8_t m_ipv6HopLimit
the socket IPv6 Hop Limit
virtual void Deserialize(TagBuffer i)
Ptr< NetDevice > m_boundnetdevice
the device this socket is bound to (might be null).
virtual int GetSockName(Address &address) const =0
Get socket address.
virtual uint32_t GetSerializedSize(void) const
void SetPriority(uint8_t priority)
Manually set the socket priority.
static uint8_t IpTos2Priority(uint8_t ipTos)
Return the priority corresponding to a given TOS value.
virtual uint32_t GetRxAvailable(void) const =0
Return number of bytes which can be returned from one or multiple calls to Recv.
void NotifySend(uint32_t spaceAvailable)
Notify through the callback (if set) that some data have been sent.
uint8_t m_ipv6Tclass
the Tclass carried by the tag
virtual uint32_t GetSerializedSize(void) const
Ipv6Address m_ipv6MulticastGroupAddress
IPv6 multicast group address.
void NotifyDataSent(uint32_t size)
Notify through the callback (if set) that some data have been sent.
bool IsManualIpTtl(void) const
Checks if the socket has a specific IPv4 TTL set.
uint8_t GetIpTos(void) const
Query the value of IP Type of Service of this socket.
virtual int ShutdownRecv(void)=0
uint8_t GetIpv6Tclass(void) const
Query the value of IPv6 Traffic Class field of this socket.
indicates whether packets should be sent out with the DF (Don't Fragment) flag set.
bool IsEnabled(void) const
Checks if the DF (Don't Fragment) flag is set.
void SetHopLimit(uint8_t hopLimit)
Set the tag's Hop Limit.
bool IsIpRecvTos(void) const
Ask if the socket is currently passing information about IP Type of Service up the stack.
static TypeId GetTypeId(void)
Get the type ID.
bool m_recvPktInfo
if the socket should add packet info tags to the packet forwarded to L4.
bool m_manualIpTtl
socket has IPv4 TTL set
void NotifyErrorClose(void)
Notify through the callback (if set) that the connection has been closed due to an error.
void NotifyNewConnectionCreated(Ptr< Socket > socket, const Address &from)
Notify through the callback (if set) that a new connection has been created.
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
uint8_t m_ipTos
the TOS carried by the tag
bool IsRecvPktInfo() const
Get status indicating whether enable/disable packet information to socket.
uint8_t m_ipTos
the socket IPv4 TOS