24 #include "ns3/packet.h" 41 .SetGroupName(
"Network");
46 : m_manualIpTtl (false),
49 m_manualIpv6Tclass (false),
50 m_manualIpv6HopLimit (false),
51 m_ipv6RecvTclass (false),
52 m_ipv6RecvHopLimit (false)
78 s = socketFactory->CreateSocket ();
148 p = Create<Packet> (buf, size);
152 p = Create<Packet> (size);
154 return Send (p, flags);
165 p = Create<Packet> (buf, size);
169 p = Create<Packet> (size);
171 return SendTo (p, flags, toAddress);
324 m_dataSent = MakeNullCallback<void,Ptr<Socket>, uint32_t> ();
325 m_sendCb = MakeNullCallback<void,Ptr<Socket>, uint32_t> ();
344 NS_ASSERT_MSG (found,
"Socket cannot be bound to a NetDevice not existing on the Node");
477 if (tclass == -1 || tclass < -1 || tclass > 0xff)
480 if (tclass < -1 || tclass > 0xff)
482 NS_LOG_WARN (
"Invalid IPV6_TCLASS value. Using default.");
566 NS_ASSERT_MSG (
false,
"Ipv6JoinGroup not implemented on this socket");
575 std::vector<Ipv6Address> sourceAddresses;
585 NS_LOG_INFO (
" The socket was not bound to any group.");
589 std::vector<Ipv6Address> sourceAddresses;
624 .SetGroupName(
"Network")
657 os <<
"Ttl=" << (uint32_t)
m_ttl;
681 static TypeId tid =
TypeId (
"ns3::SocketIpv6HopLimitTag")
683 .SetGroupName(
"Network")
743 static TypeId tid =
TypeId (
"ns3::SocketSetDontFragmentTag")
745 .SetGroupName(
"Network")
801 .SetGroupName(
"Network")
816 return sizeof (uint8_t);
858 .SetGroupName(
"Network")
873 return sizeof (uint8_t);
916 .SetGroupName(
"Network")
931 return sizeof (uint8_t);
virtual uint32_t GetSerializedSize(void) const
uint8_t m_ipv6HopLimit
the socket IPv6 Hop Limit
static TypeId GetTypeId(void)
Get the type ID.
void SetTclass(uint8_t tclass)
Set the tag's Tclass.
uint8_t GetTos(void) const
Get the tag's TOS.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
bool m_manualIpv6HopLimit
socket has IPv6 Hop Limit set
void SetIpv6RecvTclass(bool ipv6RecvTclass)
Tells a socket to pass information about IPv6 Traffic Class up the stack.
This class implements a tag that carries the socket-specific HOPLIMIT of a packet to the IPv6 layer...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
bool IsIpRecvTos(void) const
Ask if the socket is currently passing information about IP Type of Service up the stack...
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
uint8_t m_hopLimit
the Hop Limit carried by the tag
void NotifyDataRecv(void)
Notify through the callback (if set) that some data have been received.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
virtual void Serialize(TagBuffer i) const
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Ptr< Packet > Recv(void)
Read a single packet from the socket.
bool m_dontFragment
DF bit value for outgoing packets.
virtual void Ipv6JoinGroup(Ipv6Address address, Ipv6MulticastFilterMode filterMode, std::vector< Ipv6Address > sourceAddresses)
Joins a IPv6 multicast group.
void NotifyConnectionFailed(void)
Notify through the callback (if set) that the connection has not been established due to an error...
uint8_t GetTclass(void) const
Get the tag's Tclass.
uint8_t GetPriority(void) const
Get the tag's priority.
static TypeId GetTypeId(void)
Get the type ID.
Callback< bool, Ptr< Socket >, const Address & > m_connectionRequest
connection request callback
virtual void Deserialize(TagBuffer i)
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
static Ipv6Address GetAny()
Get the "any" (::) Ipv6Address.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
virtual int GetSockName(Address &address) const =0
Get socket address.
virtual void Serialize(TagBuffer i) const
void SetIpRecvTos(bool ipv4RecvTos)
Tells a socket to pass information about IP Type of Service up the stack.
bool IsIpRecvTtl(void) const
Ask if the socket is currently passing information about IP_TTL up the stack.
static TypeId GetTypeId(void)
Get the type ID.
void SetCloseCallbacks(Callback< void, Ptr< Socket > > normalClose, Callback< void, Ptr< Socket > > errorClose)
Detect socket recv() events such as graceful shutdown or error.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Callback< void, Ptr< Socket > > m_connectionSucceeded
connection succeeded callback
void SetTos(uint8_t tos)
Set the tag's TOS.
bool m_recvPktInfo
if the socket should add packet info tags to the packet forwarded to L4.
static uint8_t IpTos2Priority(uint8_t ipTos)
Return the priority corresponding to a given TOS value.
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer...
bool NotifyConnectionRequest(const Address &from)
Notify through the callback (if set) that an incoming connection is being requested by a remote host...
Ipv6Address m_ipv6MulticastGroupAddress
IPv6 multicast group address.
bool m_ipRecvTos
socket forwards IPv4 TOS tag to L4
Object to create transport layer instances that provide a socket API to applications.
virtual void Print(std::ostream &os) const
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
TAG_BUFFER_INLINE uint8_t ReadU8(void)
uint8_t m_ipv6Tclass
the socket IPv6 Tclass
a polymophic address class
uint8_t m_priority
the priority carried by the tag
virtual uint8_t GetIpTtl(void) const
Query the value of IP Time to Live field of this socket.
void SetRecvPktInfo(bool flag)
Enable/Disable receive packet information to socket.
Ptr< NetDevice > GetBoundNetDevice()
Returns socket's bound NetDevice, if any.
Ipv6MulticastFilterMode
Enumeration of the possible filter of a socket.
virtual void Serialize(TagBuffer i) const
virtual void Deserialize(TagBuffer i)
virtual uint32_t GetSerializedSize(void) const
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
void SetTtl(uint8_t ttl)
Set the tag's TTL.
uint8_t m_ipTos
the socket IPv4 TOS
uint8_t m_priority
the socket priority
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Callback< void, Ptr< Socket > > m_receivedData
data received callback
Callback< void, Ptr< Socket >, const Address & > m_newConnectionCreated
connection created callback
bool IsIpv6RecvTclass(void) const
Ask if the socket is currently passing information about IPv6 Traffic Class up the stack...
indicates whether the socket has a priority set.
static TypeId GetTypeId(void)
Get the type ID.
Callback< void, Ptr< Socket > > m_connectionFailed
connection failed callback
void NotifyDataSent(uint32_t size)
Notify through the callback (if set) that some data have been sent.
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)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
virtual void Serialize(TagBuffer i) const
virtual enum Socket::SocketType GetSocketType(void) const =0
void SetHopLimit(uint8_t hopLimit)
Set the tag's Hop Limit.
uint8_t m_ipTos
the TOS carried by the tag
void NotifyConnectionSucceeded(void)
Notify through the callback (if set) that the connection has been established.
Callback< void, Ptr< Socket > > m_errorClose
connection closed due to errors callback
virtual uint32_t GetSerializedSize(void) const
Callback< void, Ptr< Socket >, uint32_t > m_dataSent
data sent callback
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
void NotifyNormalClose(void)
Notify through the callback (if set) that the connection has been closed.
tag a set of bytes in a packet
bool IsEnabled(void) const
Checks if the DF (Don't Fragment) flag is set.
virtual uint32_t GetSerializedSize(void) const
uint8_t m_ipTtl
the socket IPv4 TTL
void SetIpv6Tclass(int ipTclass)
Manually set IPv6 Traffic Class field.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void NotifyNewConnectionCreated(Ptr< Socket > socket, const Address &from)
Notify through the callback (if set) that a new connection has been created.
bool IsManualIpv6Tclass(void) const
Checks if the socket has a specific IPv6 Tclass set.
virtual void Print(std::ostream &os) const
indicates whether the socket has IPV6_TCLASS set.
virtual void Ipv6LeaveGroup(void)
Leaves IPv6 multicast group this socket is joined to.
static TypeId GetTypeId(void)
Get the type ID.
static TypeId GetTypeId(void)
Get the type ID.
virtual void Deserialize(TagBuffer i)
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
uint8_t m_ttl
the ttl carried by the tag
void SetSendCallback(Callback< void, Ptr< Socket >, uint32_t > sendCb)
Notify application when space in transmit buffer is added.
bool m_ipRecvTtl
socket forwards IPv4 TTL tag to L4
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) ...
uint8_t GetIpv6Tclass(void) const
Query the value of IPv6 Traffic Class field of this socket.
virtual void DoDispose(void)
Destructor implementation.
static TypeId GetTypeId(void)
Get the type ID.
bool IsManualIpv6HopLimit(void) const
Checks if the socket has a specific IPv6 Hop Limit set.
void Disable(void)
Disables the DF (Don't Fragment) flag.
Describes an IPv6 address.
Ptr< NetDevice > m_boundnetdevice
the device this socket is bound to (might be null).
void SetIpv6RecvHopLimit(bool ipv6RecvHopLimit)
Tells a socket to pass information about IPv6 Hop Limit up the stack.
virtual void Serialize(TagBuffer i) const
Callback< void, Ptr< Socket > > m_normalClose
connection closed callback
void SetPriority(uint8_t priority)
Manually set the socket priority.
virtual uint8_t GetIpv6HopLimit(void) const
Query the value of IP Hop Limit field of this socket.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
virtual Ptr< Node > GetNode(void) const =0
Return the node this socket is associated with.
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
virtual void Deserialize(TagBuffer i)
indicates whether packets should be sent out with the DF (Don't Fragment) flag set.
bool IsIpv6RecvHopLimit(void) const
Ask if the socket is currently passing information about IPv6 Hop Limit up the stack.
void SetIpRecvTtl(bool ipv4RecvTtl)
Tells a socket to pass information about IP_TTL up the stack.
void Enable(void)
Enables the DF (Don't Fragment) flag.
void SetAcceptCallback(Callback< bool, Ptr< Socket >, const Address &> connectionRequest, Callback< void, Ptr< Socket >, const Address &> newConnectionCreated)
Accept connection requests from remote hosts.
uint8_t m_ipv6Tclass
the Tclass carried by the tag
virtual void Deserialize(TagBuffer i)
virtual uint32_t GetSerializedSize(void) const
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
bool IsRecvPktInfo() const
Get status indicating whether enable/disable packet information to socket.
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
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.
virtual void Serialize(TagBuffer i) const
virtual uint32_t GetSerializedSize(void) const
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.
virtual void Print(std::ostream &os) const
Callback< void, Ptr< Socket >, uint32_t > m_sendCb
packet sent callback
virtual int Send(Ptr< Packet > p, uint32_t flags)=0
Send data (or dummy data) to the remote host.
virtual void SetIpv6HopLimit(uint8_t ipHopLimit)
Manually set IPv6 Hop Limit.
void SetPriority(uint8_t priority)
Set the tag's priority.
indicates whether the socket has IP_TOS set.
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.
void SetIpTos(uint8_t ipTos)
Manually set IP Type of Service field.
a unique identifier for an interface.
uint8_t GetHopLimit(void) const
Get the tag's Hop Limit.
void NotifySend(uint32_t spaceAvailable)
Notify through the callback (if set) that some data have been sent.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
virtual void Print(std::ostream &os) const
virtual void Print(std::ostream &os) const
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...
uint8_t GetPriority(void) const
Query the priority value of this socket.
virtual void SetIpTtl(uint8_t ipTtl)
Manually set IP Time to Live field.
uint8_t GetTtl(void) const
Get the tag's TTL.
bool m_ipv6RecvHopLimit
socket forwards IPv6 Hop Limit tag to L4
uint32_t GetNDevices(void) const
bool IsAny() const
If the IPv6 address is the "Any" address.
bool m_manualIpv6Tclass
socket has IPv6 Tclass set
bool m_ipv6RecvTclass
socket forwards IPv6 Tclass tag to L4