24 #include "ns3/packet.h"
45 : m_manualIpTos (false),
46 m_manualIpTtl (false),
49 m_manualIpv6Tclass (false),
50 m_manualIpv6HopLimit (false),
51 m_ipv6RecvTclass (false),
52 m_ipv6RecvHopLimit (false)
77 s = socketFactory->CreateSocket ();
147 p = Create<Packet> (buf, size);
151 p = Create<Packet> (size);
153 return Send (p, flags);
164 p = Create<Packet> (buf, size);
168 p = Create<Packet> (size);
170 return SendTo (p, flags, toAddress);
177 return Recv (std::numeric_limits<uint32_t>::max (), 0);
197 return RecvFrom (std::numeric_limits<uint32_t>::max (), 0, fromAddress);
323 m_dataSent = MakeNullCallback<void,Ptr<Socket>, uint32_t> ();
324 m_sendCb = MakeNullCallback<void,Ptr<Socket>, uint32_t> ();
343 NS_ASSERT_MSG (found,
"Socket cannot be bound to a NetDevice not existing on the Node");
427 if (tclass == -1 || tclass < -1 || tclass > 0xff)
430 if (tclass < -1 || tclass > 0xff)
432 NS_LOG_WARN (
"Invalid IPV6_TCLASS value. Using default.");
542 .AddConstructor<SocketAddressTag> ()
602 .AddConstructor<SocketIpTtlTag> ()
634 os <<
"Ttl=" << (uint32_t)
m_ttl;
658 static TypeId tid =
TypeId (
"ns3::SocketIpv6HopLimitTag")
660 .AddConstructor<SocketIpv6HopLimitTag> ()
719 static TypeId tid =
TypeId (
"ns3::SocketSetDontFragmentTag")
721 .AddConstructor<SocketSetDontFragmentTag> ();
776 .AddConstructor<SocketIpTosTag> ()
790 return sizeof (uint8_t);
832 .AddConstructor<SocketIpv6TclassTag> ()
846 return sizeof (uint8_t);
static TypeId GetTypeId(void)
void SetTclass(uint8_t tclass)
virtual void Serialize(TagBuffer i) const
bool IsManualIpTtl(void) const
virtual void Print(std::ostream &os) const
#define NS_LOG_FUNCTION(parameters)
virtual void Print(std::ostream &os) const
bool IsIpv6RecvHopLimit(void) const
Ask if the socket is currently passing information about IPv6 Hop Limit up the stack.
bool m_manualIpv6HopLimit
virtual void Deserialize(TagBuffer i)
virtual uint8_t GetIpTtl(void) const
void SetIpv6RecvTclass(bool ipv6RecvTclass)
Tells a socket to pass information about IPv6 Traffic Class up the stack.
uint8_t GetIpTos(void) const
This class implements a tag that carries the socket-specific HOPLIMIT of a packet to the IPv6 layer...
NS_LOG_COMPONENT_DEFINE("Socket")
void NotifyDataRecv(void)
uint8_t GetTos(void) const
virtual uint32_t GetSerializedSize(void) const
Ptr< Packet > Recv(void)
Read a single packet from the socket.
void SetAddress(Address addr)
virtual void Serialize(TagBuffer i) const
void NotifyConnectionFailed(void)
static TypeId GetTypeId(void)
Callback< bool, Ptr< Socket >, const Address & > m_connectionRequest
virtual void Deserialize(TagBuffer i)
#define NS_ASSERT(condition)
virtual int GetSockName(Address &address) const =0
void SetIpRecvTos(bool ipv4RecvTos)
Tells a socket to pass information about IP Type of Service up the stack.
virtual TypeId GetInstanceTypeId(void) const
uint32_t GetSize(void) const
static TypeId GetTypeId(void)
bool IsManualIpTos(void) const
virtual TypeId GetInstanceTypeId(void) const
void SetCloseCallbacks(Callback< void, Ptr< Socket > > normalClose, Callback< void, Ptr< Socket > > errorClose)
Detect socket recv() events such as graceful shutdown or error.
virtual uint8_t GetIpv6HopLimit(void) const
#define NS_LOG_FUNCTION_NOARGS()
Callback< void, Ptr< Socket > > m_connectionSucceeded
bool IsEnabled(void) const
virtual void Serialize(TagBuffer i) const
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer...
bool NotifyConnectionRequest(const Address &from)
Object to create transport layer instances that provide a socket API to applications.
virtual void Print(std::ostream &os) const
bool IsRecvPktInfo() const
Get status indicating whether enable/disable packet information to socket.
TAG_BUFFER_INLINE uint8_t ReadU8(void)
a polymophic address class
bool IsIpRecvTos(void) const
Ask if the socket is currently passing information about IP Type of Service up the stack...
void SetRecvPktInfo(bool flag)
Enable/Disable receive packet information to socket.
Ptr< NetDevice > GetBoundNetDevice()
Returns socket's bound netdevice, if any.
uint8_t GetTclass(void) const
static TypeId GetTypeId(void)
Callback< void, Ptr< Socket > > m_receivedData
Callback< void, Ptr< Socket >, const Address & > m_newConnectionCreated
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
static TypeId GetTypeId(void)
Ptr< NetDevice > GetDevice(uint32_t index) const
This class implements a tag that carries an address of a packet across the socket interface...
Callback< void, Ptr< Socket > > m_connectionFailed
bool IsManualIpv6Tclass(void) const
void NotifyDataSent(uint32_t size)
void SetRecvCallback(Callback< void, Ptr< Socket > >)
Notify application when new data is available to be read.
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
virtual void Print(std::ostream &os) const
void SetHopLimit(uint8_t hopLimit)
void Deserialize(TagBuffer buffer)
void NotifyConnectionSucceeded(void)
uint32_t GetSerializedSize(void) const
Callback< void, Ptr< Socket > > m_errorClose
uint32_t GetNDevices(void) const
Callback< void, Ptr< Socket >, uint32_t > m_dataSent
bool IsManualIpv6HopLimit(void) const
virtual uint32_t GetSerializedSize(void) const
void NotifyNormalClose(void)
tag a set of bytes in a packet
void SetIpv6Tclass(int ipTclass)
virtual void Serialize(TagBuffer i) const
void NotifyNewConnectionCreated(Ptr< Socket > socket, const Address &from)
virtual uint32_t GetSerializedSize(void) const
uint8_t GetIpv6Tclass(void) const
static TypeId GetTypeId(void)
virtual TypeId GetInstanceTypeId(void) const
virtual void Deserialize(TagBuffer i)
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
bool IsIpv6RecvTclass(void) const
Ask if the socket is currently passing information about IPv6 Traffic Class up the stack...
void SetSendCallback(Callback< void, Ptr< Socket >, uint32_t > sendCb)
Notify application when space in transmit buffer is added.
void SetAcceptCallback(Callback< bool, Ptr< Socket >, const Address & > connectionRequest, Callback< void, Ptr< Socket >, const Address & > newConnectionCreated)
Accept connection requests from remote hosts.
virtual void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
SocketSetDontFragmentTag()
void SetDataSentCallback(Callback< void, Ptr< Socket >, uint32_t > dataSent)
Notify application when a packet has been sent from transport protocol (non-standard socket call) ...
virtual void DoDispose(void)
#define NS_ASSERT_MSG(condition, message)
bool IsIpRecvTtl(void) const
Ask if the socket is currently passing information about IP_TTL up the stack.
static TypeId GetTypeId(void)
uint8_t GetHopLimit(void) const
Ptr< NetDevice > m_boundnetdevice
void Serialize(TagBuffer buffer) const
void SetIpv6RecvHopLimit(bool ipv6RecvHopLimit)
Tells a socket to pass information about IPv6 Hop Limit up the stack.
Callback< void, Ptr< Socket > > m_normalClose
virtual uint32_t GetSerializedSize(void) const
virtual TypeId GetInstanceTypeId(void) const
virtual void Serialize(TagBuffer i) const
virtual Ptr< Node > GetNode(void) const =0
Address GetAddress(void) const
virtual void Print(std::ostream &os) const
virtual void Deserialize(TagBuffer i)
indicated whether packets should be sent out with the DF flag set.
virtual void Serialize(TagBuffer i) const
void SetIpRecvTtl(bool ipv4RecvTtl)
Tells a socket to pass information about IP_TTL up the stack.
virtual void Deserialize(TagBuffer i)
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
virtual void Deserialize(TagBuffer i)
virtual void Print(std::ostream &os) const
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.
a base class which provides memory management and object aggregation
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.
uint8_t GetTtl(void) const
virtual uint32_t GetSerializedSize(void) const
Callback< void, Ptr< Socket >, uint32_t > m_sendCb
virtual int Send(Ptr< Packet > p, uint32_t flags)=0
Send data (or dummy data) to the remote host.
virtual TypeId GetInstanceTypeId(void) const
virtual void SetIpv6HopLimit(uint8_t ipHopLimit)
virtual uint32_t GetSerializedSize(void) const
Ptr< T > GetObject(void) const
void SetIpTos(uint8_t ipTos)
virtual TypeId GetInstanceTypeId(void) const
a unique identifier for an interface.
void NotifySend(uint32_t spaceAvailable)
TypeId SetParent(TypeId tid)
void NotifyErrorClose(void)
virtual void SetIpTtl(uint8_t ipTtl)