21 #ifndef PACKET_SOCKET_H
22 #define PACKET_SOCKET_H
26 #include "ns3/callback.h"
27 #include "ns3/traced-callback.h"
29 #include "ns3/socket.h"
30 #include "ns3/net-device.h"
37 class PacketSocketAddress;
91 virtual int Bind (
void);
92 virtual int Bind6 (
void);
94 virtual int Close (
void);
181 virtual void Print (std::ostream &os)
const;
214 virtual void Print (std::ostream &os)
const;
static TypeId GetTypeId(void)
virtual enum SocketErrno GetErrno(void) const
Get last error number.
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
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
std::queue< Ptr< Packet > > m_deliveryQueue
Default destination address.
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.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
A PacketSocket is a link between an application and a net device.
virtual uint32_t GetSerializedSize(void) const
void SetPacketType(NetDevice::PacketType t)
Set the packet type.
virtual int Bind(void)
Allocate a local IPv4 endpoint for this socket.
virtual void Print(std::ostream &os) const
virtual int GetSockName(Address &address) const
Get socket address.
SocketErrno
Enumeration of the possible errors returned by a socket.
a polymophic address class
virtual TypeId GetInstanceTypeId(void) const
virtual void Serialize(TagBuffer i) const
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)
virtual uint32_t GetSerializedSize(void) const
static TypeId GetTypeId(void)
PacketSocketTag()
Create an empty PacketSocketTag.
virtual Ptr< Node > GetNode(void) const
Return the node this socket is associated with.
virtual int Listen(void)
Listen for incoming connections.
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
virtual int Send(Ptr< Packet > p, uint32_t flags)
Send data (or dummy data) to the remote host.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)
Send data to a specified peer.
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.
virtual void Deserialize(TagBuffer i)
virtual int Close(void)
Close a socket.
void SetNode(Ptr< Node > node)
static TypeId GetTypeId(void)
int DoBind(const PacketSocketAddress &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
NetDevice::PacketType GetPacketType(void) const
Get the packet type.
virtual void Print(std::ostream &os) const
DeviceNameTag()
Create an empty DeviceNameTag.
virtual TypeId GetInstanceTypeId(void) const
virtual int Connect(const Address &address)
Initiate a connection to a remote host.
uint32_t GetMinMtu(PacketSocketAddress ad) const
virtual int Bind6(void)
Allocate a local IPv6 endpoint for this socket.
std::string GetDeviceName(void) const
Get the device name from where the corresponding packet is coming.
PacketType
Packet types are used as they are in Linux.
This class implements a tag that carries the dest address of a packet and the packet type...
TracedCallback< Ptr< const Packet > > m_dropTrace
virtual int ShutdownSend(void)
SocketType
Enumeration of the possible socket types.
a unique identifier for an interface.
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)
void SetDeviceName(std::string n)
Set the device name.