|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
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;
121 virtual int Bind (
void);
129 virtual int Bind6 (
void);
138 virtual int Close (
void);
142 virtual int Listen (
void);
256 virtual void Print (std::ostream &os)
const;
291 virtual void Print (std::ostream &os)
const;
a unique identifier for an interface.
virtual uint32_t GetSerializedSize(void) const
static TypeId GetTypeId(void)
Get the type ID.
enum SocketErrno m_errno
Socket error code.
uint32_t GetMinMtu(PacketSocketAddress ad) const
Get the minimum MTU supported by the NetDevices bound to a specific address.
virtual int Close(void)
Close a socket.
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
SocketErrno
Enumeration of the possible errors returned by a socket.
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)
PacketSocketTag()
Create an empty PacketSocketTag.
virtual uint32_t GetSerializedSize(void) const
static TypeId GetTypeId(void)
Get the type ID.
an address for a packet socket
Ptr< Node > m_node
the associated node
virtual enum SocketErrno GetErrno(void) const
Get last error number.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
enum State m_state
Socket state.
virtual Ptr< Node > GetNode(void) const
Return the node this socket is associated with.
virtual void Print(std::ostream &os) const
State
States of the socket.
void SetNode(Ptr< Node > node)
Set the associated node.
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
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.
SocketType
Enumeration of the possible socket types.
uint32_t m_rcvBufSize
Rx buffer size [Bytes].
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 int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)
Send data to a specified peer.
virtual bool SetAllowBroadcast(bool allowBroadcast)
Configure whether broadcast datagram transmissions are allowed.
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
virtual int Bind(void)
Bind the socket to the NetDevice and register the protocol handler.
std::string m_deviceName
Device name.
NetDevice::PacketType m_packetType
Packet type.
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.
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.
virtual int ShutdownSend(void)
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.
PacketType
Packet types are used as they are in Linux.
Forward calls to a chain of Callback.
virtual int Bind6(void)
Bind the socket to the NetDevice and register the protocol handler.
virtual bool GetAllowBroadcast() const
Query whether broadcast datagram transmissions are allowed.
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.
void SetDeviceName(std::string n)
Set the device name.
This class implements a tag that carries the ns3 device name from where a packet is coming.
std::string GetDeviceName(void) const
Get the device name from where the corresponding packet is coming.
bool m_shutdownSend
Send no longer allowed.