|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
26 #include "ns3/packet.h"
27 #include "ns3/uinteger.h"
28 #include "ns3/trace-source-accessor.h"
43 .SetGroupName(
"Network")
45 .AddTraceSource (
"Drop",
"Drop packet due to receive buffer overflow",
47 "ns3::Packet::TracedCallback")
48 .AddAttribute (
"RcvBufSize",
49 "PacketSocket maximum receive buffer size (bytes)",
52 MakeUintegerChecker<uint32_t> ())
283 uint32_t minMtu = 0xffff;
388 uint16_t protocol,
const Address &from,
391 NS_LOG_FUNCTION (
this << device << packet << protocol << from << to << packetType);
397 address.SetPhysicalAddress (from);
399 address.SetProtocol (protocol);
426 NS_LOG_WARN (
"No receive buffer space available. Drop.");
570 .SetGroupName(
"Network")
614 if (
n.substr(0,5) ==
"ns3::" )
634 .SetGroupName(
"Network")
656 i.
Write ( (uint8_t*)
n , (uint32_t) l);
664 i.
Read ( (uint8_t* ) buf, (uint32_t) l);
a unique identifier for an interface.
virtual uint32_t GetSerializedSize(void) const
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void Deserialize(TagBuffer buffer)
void NotifyConnectionSucceeded(void)
Notify through the callback (if set) that the connection has been established.
static TypeId GetTypeId(void)
Get the type ID.
enum SocketErrno m_errno
Socket error code.
bool ReplacePacketTag(Tag &tag)
Replace the value of a packet tag.
uint32_t GetMinMtu(PacketSocketAddress ad) const
Get the minimum MTU supported by the NetDevices bound to a specific address.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
virtual int Close(void)
Close a socket.
void RegisterProtocolHandler(ProtocolHandler handler, uint16_t protocolType, Ptr< NetDevice > device, bool promiscuous=false)
static TypeId GetTypeId(void)
Get the type ID.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)
Read a single packet from the socket and retrieve the sender address.
virtual uint32_t GetRxAvailable(void) const
Return number of bytes which can be returned from one or multiple calls to Recv.
bool m_shutdownRecv
Receive no longer allowed.
virtual void Serialize(TagBuffer i) const
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
SocketErrno
Enumeration of the possible errors returned by a socket.
virtual Address GetAddress(void) const =0
static TypeId GetTypeId(void)
Get the type ID.
virtual void Deserialize(TagBuffer i)
virtual int Listen(void)
Listen for incoming connections.
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 int ShutdownRecv(void)
uint16_t GetProtocol(void) const
Get the protocol.
PacketSocketTag()
Create an empty PacketSocketTag.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
virtual uint32_t GetSerializedSize(void) const
static TypeId GetTypeId(void)
Get the type ID.
an address for a packet socket
virtual uint16_t GetMtu(void) const =0
Ptr< Node > m_node
the associated node
void UnregisterProtocolHandler(ProtocolHandler handler)
virtual enum SocketErrno GetErrno(void) const
Get last error number.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
void SetAllDevices(void)
Set the address to match all the outgoing NetDevice.
static bool IsMatchingType(const Address &address)
enum State m_state
Socket state.
void SetPriority(uint8_t priority)
Set the tag's priority.
virtual Ptr< Node > GetNode(void) const
Return the node this socket is associated with.
virtual void Print(std::ostream &os) const
void SetNode(Ptr< Node > node)
Set the associated node.
void Write(const uint8_t *buffer, uint32_t size)
virtual int Connect(const Address &address)
Initiate a connection to a remote host.
virtual void Print(std::ostream &os) const
A low-level Socket API based loosely on the BSD Socket API.
tag a set of bytes in a packet
a polymophic address class
TAG_BUFFER_INLINE uint8_t ReadU8(void)
NetDevice::PacketType GetPacketType(void) const
Get the packet type.
uint32_t m_device
index of the bound NetDevice
int DoBind(const PacketSocketAddress &address)
Bind the socket to the NetDevice and register the protocol handler specified in the address.
std::queue< std::pair< Ptr< Packet >, Address > > m_deliveryQueue
Rx queue.
virtual int GetSockName(Address &address) const
Get socket address.
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
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.
uint32_t m_rcvBufSize
Rx buffer size [Bytes].
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)=0
uint32_t GetSingleDevice(void) const
Get the device this address is bound to.
Address GetPhysicalAddress(void) const
Get the destination address.
uint32_t m_rxAvailable
Rx queue size [Bytes].
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
virtual uint32_t GetTxAvailable(void) const
Returns the number of bytes which can be sent in a single call to Send.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)
Send data to a specified peer.
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
virtual bool SetAllowBroadcast(bool allowBroadcast)
Configure whether broadcast datagram transmissions are allowed.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
A PacketSocket is a link between an application and a net device.
virtual enum SocketType GetSocketType(void) const
virtual void DoDispose(void)
Destructor implementation.
virtual void Serialize(TagBuffer i) const
void AddPacketTag(const Tag &tag) const
Add a packet tag.
virtual int Bind(void)
Bind the socket to the NetDevice and register the protocol handler.
std::string GetName(void) const
Get the name.
indicates whether the socket has a priority set.
std::string m_deviceName
Device name.
NetDevice::PacketType m_packetType
Packet type.
void NotifyDataRecv(void)
Notify through the callback (if set) that some data have been received.
Address m_destAddr
Default destination address.
virtual void Deserialize(TagBuffer i)
uint16_t m_protocol
Socket protocol.
Address m_destAddr
Destination address.
virtual int Send(Ptr< Packet > p, uint32_t flags)
Send data (or dummy data) to the remote host.
void Read(uint8_t *buffer, uint32_t size)
virtual int GetPeerName(Address &address) const
Get the peer address of a connected socket.
void ForwardUp(Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType)
Called by the L3 protocol when it received a packet to pass on to TCP.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
void SetPhysicalAddress(const Address address)
Set the destination address.
uint32_t pktSize
packet size used for the simulation (in bytes)
uint8_t GetPriority(void) const
Query the priority value of this socket.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
virtual int ShutdownSend(void)
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Address GetDestAddress(void) const
Get the destination address of the corresponding packet.
void SetDestAddress(Address a)
Set the destination address of the corresponding packet.
This class implements a tag that carries the dest address of a packet and the packet type.
DeviceNameTag()
Create an empty DeviceNameTag.
uint32_t GetSerializedSize(void) const
Get the number of bytes needed to serialize the underlying Address Typically, this is GetLength () + ...
void SetProtocol(uint16_t protocol)
Set the protocol.
PacketType
Packet types are used as they are in Linux.
Hold an unsigned integer type.
virtual int Bind6(void)
Bind the socket to the NetDevice and register the protocol handler.
void Serialize(TagBuffer buffer) const
Serialize this address in host byte order to a byte buffer.
virtual bool GetAllowBroadcast() const
Query whether broadcast datagram transmissions are allowed.
uint32_t GetNDevices(void) const
void SetPacketType(NetDevice::PacketType t)
Set the packet type.
bool m_isSingleDevice
Is bound to a single netDevice.
TracedCallback< Ptr< const Packet > > m_dropTrace
Traced callback: dropped packets.
Ptr< NetDevice > m_boundnetdevice
the device this socket is bound to (might be null).
bool IsSingleDevice(void) const
Checks if the address is bound to a specified NetDevice.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
void NotifySend(uint32_t spaceAvailable)
Notify through the callback (if set) that some data have been sent.
void SetDeviceName(std::string n)
Set the device name.
void NotifyDataSent(uint32_t size)
Notify through the callback (if set) that some data have been sent.
virtual uint32_t GetIfIndex(void) const =0
This class implements a tag that carries the ns3 device name from where a packet is coming.
static PacketSocketAddress ConvertFrom(const Address &address)
std::string GetDeviceName(void) const
Get the device name from where the corresponding packet is coming.
uint64_t GetUid(void) const
Returns the packet's Uid.
bool m_shutdownSend
Send no longer allowed.