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