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