A Discrete-Event Network Simulator
API
socket.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2006 Georgia Tech Research Corporation
4  * 2007 INRIA
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Authors: George F. Riley<riley@ece.gatech.edu>
20  * Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
21  */
22 
23 #ifndef NS3_SOCKET_H
24 #define NS3_SOCKET_H
25 
26 #include "ns3/callback.h"
27 #include "ns3/ptr.h"
28 #include "ns3/tag.h"
29 #include "ns3/object.h"
30 #include "ns3/net-device.h"
31 #include "address.h"
32 #include <stdint.h>
33 #include "ns3/inet-socket-address.h"
34 #include "ns3/inet6-socket-address.h"
35 
36 namespace ns3 {
37 
38 
39 class Node;
40 class Packet;
41 
66 class Socket : public Object
67 {
68 public:
73  static TypeId GetTypeId (void);
74 
75  Socket (void);
76  virtual ~Socket (void);
77 
82  enum SocketErrno {
98  };
99 
104  enum SocketType {
109  };
110 
124  NS3_PRIO_CONTROL = 7
125  };
126 
139  {
141  EXCLUDE
142  };
143 
161  virtual enum Socket::SocketErrno GetErrno (void) const = 0;
165  virtual enum Socket::SocketType GetSocketType (void) const = 0;
170  virtual Ptr<Node> GetNode (void) const = 0;
183  void SetConnectCallback (Callback<void, Ptr<Socket> > connectionSucceeded,
184  Callback<void, Ptr<Socket> > connectionFailed);
200  void SetCloseCallbacks (Callback<void, Ptr<Socket> > normalClose,
201  Callback<void, Ptr<Socket> > errorClose);
220  const Address &> connectionRequest,
221  Callback<void, Ptr<Socket>,
222  const Address&> newConnectionCreated);
231  uint32_t> dataSent);
246  void SetSendCallback (Callback<void, Ptr<Socket>, uint32_t> sendCb);
257  void SetRecvCallback (Callback<void, Ptr<Socket> > receivedData);
263  virtual int Bind (const Address &address) = 0;
264 
270  virtual int Bind () = 0;
271 
277  virtual int Bind6 () = 0;
278 
286  virtual int Close (void) = 0;
287 
294  virtual int ShutdownSend (void) = 0;
295 
302  virtual int ShutdownRecv (void) = 0;
303 
309  virtual int Connect (const Address &address) = 0;
310 
315  virtual int Listen (void) = 0;
316 
329  virtual uint32_t GetTxAvailable (void) const = 0;
330 
376  virtual int Send (Ptr<Packet> p, uint32_t flags) = 0;
377 
391  virtual int SendTo (Ptr<Packet> p, uint32_t flags,
392  const Address &toAddress) = 0;
393 
402  virtual uint32_t GetRxAvailable (void) const = 0;
403 
455  virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags) = 0;
456 
476  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
477  Address &fromAddress) = 0;
478 
480  // The remainder of these public methods are overloaded methods //
481  // or variants of Send() and Recv(), and they are non-virtual //
483 
493  int Send (Ptr<Packet> p);
494 
509  int Send (const uint8_t* buf, uint32_t size, uint32_t flags);
510 
511 
528  int SendTo (const uint8_t* buf, uint32_t size, uint32_t flags,
529  const Address &address);
530 
540  Ptr<Packet> Recv (void);
541 
556  int Recv (uint8_t* buf, uint32_t size, uint32_t flags);
557 
571  Ptr<Packet> RecvFrom (Address &fromAddress);
572 
590  int RecvFrom (uint8_t* buf, uint32_t size, uint32_t flags,
591  Address &fromAddress);
597  virtual int GetSockName (Address &address) const = 0;
598 
604  virtual int GetPeerName (Address &address) const = 0;
605 
624  virtual void BindToNetDevice (Ptr<NetDevice> netdevice);
625 
636 
637 
649  virtual bool SetAllowBroadcast (bool allowBroadcast) = 0;
650 
659  virtual bool GetAllowBroadcast () const = 0;
660 
672  void SetRecvPktInfo (bool flag);
673 
679  bool IsRecvPktInfo () const;
680 
693  void SetPriority (uint8_t priority);
694 
703  uint8_t GetPriority (void) const;
704 
781  static uint8_t IpTos2Priority (uint8_t ipTos);
782 
793  void SetIpTos (uint8_t ipTos);
794 
803  uint8_t GetIpTos (void) const;
804 
816  void SetIpRecvTos (bool ipv4RecvTos);
817 
826  bool IsIpRecvTos (void) const;
827 
838  void SetIpv6Tclass (int ipTclass);
839 
848  uint8_t GetIpv6Tclass (void) const;
849 
861  void SetIpv6RecvTclass (bool ipv6RecvTclass);
862 
871  bool IsIpv6RecvTclass (void) const;
872 
881  virtual void SetIpTtl (uint8_t ipTtl);
882 
891  virtual uint8_t GetIpTtl (void) const;
892 
904  void SetIpRecvTtl (bool ipv4RecvTtl);
905 
914  bool IsIpRecvTtl (void) const;
915 
924  virtual void SetIpv6HopLimit (uint8_t ipHopLimit);
925 
934  virtual uint8_t GetIpv6HopLimit (void) const;
935 
947  void SetIpv6RecvHopLimit (bool ipv6RecvHopLimit);
948 
957  bool IsIpv6RecvHopLimit (void) const;
958 
972  virtual void Ipv6JoinGroup (Ipv6Address address, Ipv6MulticastFilterMode filterMode, std::vector<Ipv6Address> sourceAddresses);
973 
981  virtual void Ipv6JoinGroup (Ipv6Address address);
982 
986  virtual void Ipv6LeaveGroup (void);
987 
988 protected:
993  void NotifyConnectionSucceeded (void);
994 
999  void NotifyConnectionFailed (void);
1000 
1005  void NotifyNormalClose (void);
1006 
1011  void NotifyErrorClose (void);
1012 
1024  bool NotifyConnectionRequest (const Address &from);
1025 
1032  void NotifyNewConnectionCreated (Ptr<Socket> socket, const Address &from);
1033 
1039  void NotifyDataSent (uint32_t size);
1040 
1046  void NotifySend (uint32_t spaceAvailable);
1047 
1051  void NotifyDataRecv (void);
1052 
1053  // inherited function, no doc necessary
1054  virtual void DoDispose (void);
1055 
1061  bool IsManualIpv6Tclass (void) const;
1062 
1068  bool IsManualIpTtl (void) const;
1069 
1075  bool IsManualIpv6HopLimit (void) const;
1076 
1080 
1081 private:
1091 
1092  uint8_t m_priority;
1093 
1094  //IPv4 options
1098 
1099  uint8_t m_ipTos;
1100  uint8_t m_ipTtl;
1101 
1102  //IPv6 options
1107 
1108  uint8_t m_ipv6Tclass;
1109  uint8_t m_ipv6HopLimit;
1110 };
1111 
1116 class SocketIpTtlTag : public Tag
1117 {
1118 public:
1119  SocketIpTtlTag ();
1120 
1126  void SetTtl (uint8_t ttl);
1127 
1133  uint8_t GetTtl (void) const;
1134 
1139  static TypeId GetTypeId (void);
1140 
1141  // inherited function, no need to doc.
1142  virtual TypeId GetInstanceTypeId (void) const;
1143 
1144  // inherited function, no need to doc.
1145  virtual uint32_t GetSerializedSize (void) const;
1146 
1147  // inherited function, no need to doc.
1148  virtual void Serialize (TagBuffer i) const;
1149 
1150  // inherited function, no need to doc.
1151  virtual void Deserialize (TagBuffer i);
1152 
1153  // inherited function, no need to doc.
1154  virtual void Print (std::ostream &os) const;
1155 
1156 private:
1157  uint8_t m_ttl;
1158 };
1159 
1165 {
1166 public:
1168 
1174  void SetHopLimit (uint8_t hopLimit);
1175 
1181  uint8_t GetHopLimit (void) const;
1182 
1187  static TypeId GetTypeId (void);
1188 
1189  // inherited function, no need to doc.
1190  virtual TypeId GetInstanceTypeId (void) const;
1191 
1192  // inherited function, no need to doc.
1193  virtual uint32_t GetSerializedSize (void) const;
1194 
1195  // inherited function, no need to doc.
1196  virtual void Serialize (TagBuffer i) const;
1197 
1198  // inherited function, no need to doc.
1199  virtual void Deserialize (TagBuffer i);
1200 
1201  // inherited function, no need to doc.
1202  virtual void Print (std::ostream &os) const;
1203 
1204 private:
1205  uint8_t m_hopLimit;
1206 };
1207 
1213 {
1214 public:
1216 
1220  void Enable (void);
1221 
1225  void Disable (void);
1226 
1232  bool IsEnabled (void) const;
1233 
1238  static TypeId GetTypeId (void);
1239 
1240  // inherited function, no need to doc.
1241  virtual TypeId GetInstanceTypeId (void) const;
1242 
1243  // inherited function, no need to doc.
1244  virtual uint32_t GetSerializedSize (void) const;
1245 
1246  // inherited function, no need to doc.
1247  virtual void Serialize (TagBuffer i) const;
1248 
1249  // inherited function, no need to doc.
1250  virtual void Deserialize (TagBuffer i);
1251 
1252  // inherited function, no need to doc.
1253  virtual void Print (std::ostream &os) const;
1254 private:
1256 };
1257 
1262 class SocketIpTosTag : public Tag
1263 {
1264 public:
1265  SocketIpTosTag ();
1266 
1272  void SetTos (uint8_t tos);
1273 
1279  uint8_t GetTos (void) const;
1280 
1285  static TypeId GetTypeId (void);
1286 
1287  // inherited function, no need to doc.
1288  virtual TypeId GetInstanceTypeId (void) const;
1289 
1290  // inherited function, no need to doc.
1291  virtual uint32_t GetSerializedSize (void) const;
1292 
1293  // inherited function, no need to doc.
1294  virtual void Serialize (TagBuffer i) const;
1295 
1296  // inherited function, no need to doc.
1297  virtual void Deserialize (TagBuffer i);
1298 
1299  // inherited function, no need to doc.
1300  virtual void Print (std::ostream &os) const;
1301 private:
1302  uint8_t m_ipTos;
1303 };
1304 
1308 class SocketPriorityTag : public Tag
1309 {
1310 public:
1311  SocketPriorityTag ();
1312 
1318  void SetPriority (uint8_t priority);
1319 
1325  uint8_t GetPriority (void) const;
1326 
1331  static TypeId GetTypeId (void);
1332 
1333  // inherited function, no need to doc.
1334  virtual TypeId GetInstanceTypeId (void) const;
1335 
1336  // inherited function, no need to doc.
1337  virtual uint32_t GetSerializedSize (void) const;
1338 
1339  // inherited function, no need to doc.
1340  virtual void Serialize (TagBuffer i) const;
1341 
1342  // inherited function, no need to doc.
1343  virtual void Deserialize (TagBuffer i);
1344 
1345  // inherited function, no need to doc.
1346  virtual void Print (std::ostream &os) const;
1347 private:
1348  uint8_t m_priority;
1349 };
1350 
1355 class SocketIpv6TclassTag : public Tag
1356 {
1357 public:
1359 
1365  void SetTclass (uint8_t tclass);
1366 
1372  uint8_t GetTclass (void) const;
1373 
1378  static TypeId GetTypeId (void);
1379 
1380  // inherited function, no need to doc.
1381  virtual TypeId GetInstanceTypeId (void) const;
1382 
1383  // inherited function, no need to doc.
1384  virtual uint32_t GetSerializedSize (void) const;
1385 
1386  // inherited function, no need to doc.
1387  virtual void Serialize (TagBuffer i) const;
1388 
1389  // inherited function, no need to doc.
1390  virtual void Deserialize (TagBuffer i);
1391 
1392  // inherited function, no need to doc.
1393  virtual void Print (std::ostream &os) const;
1394 private:
1395  uint8_t m_ipv6Tclass;
1396 };
1397 
1398 } // namespace ns3
1399 
1400 #endif /* NS3_SOCKET_H */
a polymophic address class
Definition: address.h:91
Callback template class.
Definition: callback.h:1279
Describes an IPv6 address.
Definition: ipv6-address.h:50
A base class which provides memory management and object aggregation.
Definition: object.h:88
A low-level Socket API based loosely on the BSD Socket API.
Definition: socket.h:67
virtual int Send(Ptr< Packet > p, uint32_t flags)=0
Send data (or dummy data) to the remote host.
Ptr< NetDevice > GetBoundNetDevice()
Returns socket's bound NetDevice, if any.
Definition: socket.cc:351
virtual void SetIpTtl(uint8_t ipTtl)
Manually set IP Time to Live field.
Definition: socket.cc:513
bool IsManualIpv6HopLimit(void) const
Checks if the socket has a specific IPv6 Hop Limit set.
Definition: socket.cc:383
Callback< void, Ptr< Socket > > m_normalClose
connection closed callback
Definition: socket.h:1084
uint8_t GetIpv6Tclass(void) const
Query the value of IPv6 Traffic Class field of this socket.
Definition: socket.cc:495
uint8_t GetPriority(void) const
Query the priority value of this socket.
Definition: socket.cc:396
bool m_ipv6RecvHopLimit
socket forwards IPv6 Hop Limit tag to L4
Definition: socket.h:1106
uint8_t m_ipTos
the socket IPv4 TOS
Definition: socket.h:1099
void SetConnectCallback(Callback< void, Ptr< Socket > > connectionSucceeded, Callback< void, Ptr< Socket > > connectionFailed)
Specify callbacks to allow the caller to determine if the connection succeeds of fails.
Definition: socket.cc:84
bool IsIpRecvTtl(void) const
Ask if the socket is currently passing information about IP_TTL up the stack.
Definition: socket.cc:532
uint8_t m_priority
the socket priority
Definition: socket.h:1092
Socket(void)
Definition: socket.cc:45
void SetIpTos(uint8_t ipTos)
Manually set IP Type of Service field.
Definition: socket.cc:437
bool m_manualIpv6HopLimit
socket has IPv6 Hop Limit set
Definition: socket.h:1104
void NotifyConnectionSucceeded(void)
Notify through the callback (if set) that the connection has been established.
Definition: socket.cc:217
virtual bool SetAllowBroadcast(bool allowBroadcast)=0
Configure whether broadcast datagram transmissions are allowed.
void SetRecvPktInfo(bool flag)
Enable/Disable receive packet information to socket.
Definition: socket.cc:358
void NotifySend(uint32_t spaceAvailable)
Notify through the callback (if set) that some data have been sent.
Definition: socket.cc:295
void NotifyConnectionFailed(void)
Notify through the callback (if set) that the connection has not been established due to an error.
Definition: socket.cc:227
void NotifyNewConnectionCreated(Ptr< Socket > socket, const Address &from)
Notify through the callback (if set) that a new connection has been created.
Definition: socket.cc:275
Callback< void, Ptr< Socket > > m_connectionFailed
connection failed callback
Definition: socket.h:1083
void SetAcceptCallback(Callback< bool, Ptr< Socket >, const Address & > connectionRequest, Callback< void, Ptr< Socket >, const Address & > newConnectionCreated)
Accept connection requests from remote hosts.
Definition: socket.cc:104
bool IsRecvPktInfo() const
Get status indicating whether enable/disable packet information to socket.
Definition: socket.cc:364
bool NotifyConnectionRequest(const Address &from)
Notify through the callback (if set) that an incoming connection is being requested by a remote host.
Definition: socket.cc:257
uint8_t m_ipTtl
the socket IPv4 TTL
Definition: socket.h:1100
uint8_t m_ipv6HopLimit
the socket IPv6 Hop Limit
Definition: socket.h:1109
virtual void DoDispose(void)
Destructor implementation.
Definition: socket.cc:315
void SetIpRecvTos(bool ipv4RecvTos)
Tells a socket to pass information about IP Type of Service up the stack.
Definition: socket.cc:459
bool IsIpv6RecvHopLimit(void) const
Ask if the socket is currently passing information about IPv6 Hop Limit up the stack.
Definition: socket.cc:557
Ipv6Address m_ipv6MulticastGroupAddress
IPv6 multicast group address.
Definition: socket.h:1079
virtual int ShutdownRecv(void)=0
bool m_ipRecvTos
socket forwards IPv4 TOS tag to L4
Definition: socket.h:1096
bool IsIpv6RecvTclass(void) const
Ask if the socket is currently passing information about IPv6 Traffic Class up the stack.
Definition: socket.cc:507
static TypeId GetTypeId(void)
Get the type ID.
Definition: socket.cc:37
virtual int Bind()=0
Allocate a local IPv4 endpoint for this socket.
virtual int Bind6()=0
Allocate a local IPv6 endpoint for this socket.
SocketType
Enumeration of the possible socket types.
Definition: socket.h:104
@ NS3_SOCK_STREAM
Definition: socket.h:105
@ NS3_SOCK_DGRAM
Definition: socket.h:107
@ NS3_SOCK_SEQPACKET
Definition: socket.h:106
@ NS3_SOCK_RAW
Definition: socket.h:108
virtual int Listen(void)=0
Listen for incoming connections.
void NotifyNormalClose(void)
Notify through the callback (if set) that the connection has been closed.
Definition: socket.cc:237
virtual void SetIpv6HopLimit(uint8_t ipHopLimit)
Manually set IPv6 Hop Limit.
Definition: socket.cc:538
uint8_t m_ipv6Tclass
the socket IPv6 Tclass
Definition: socket.h:1108
bool m_recvPktInfo
if the socket should add packet info tags to the packet forwarded to L4.
Definition: socket.h:1078
Callback< void, Ptr< Socket > > m_connectionSucceeded
connection succeeded callback
Definition: socket.h:1082
void SetDataSentCallback(Callback< void, Ptr< Socket >, uint32_t > dataSent)
Notify application when a packet has been sent from transport protocol (non-standard socket call)
Definition: socket.cc:114
virtual int GetPeerName(Address &address) const =0
Get the peer address of a connected socket.
static uint8_t IpTos2Priority(uint8_t ipTos)
Return the priority corresponding to a given TOS value.
Definition: socket.cc:402
virtual int ShutdownSend(void)=0
virtual ~Socket(void)
Definition: socket.cc:65
void SetSendCallback(Callback< void, Ptr< Socket >, uint32_t > sendCb)
Notify application when space in transmit buffer is added.
Definition: socket.cc:121
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
bool IsManualIpTtl(void) const
Checks if the socket has a specific IPv4 TTL set.
Definition: socket.cc:377
void SetPriority(uint8_t priority)
Manually set the socket priority.
Definition: socket.cc:389
bool m_ipv6RecvTclass
socket forwards IPv6 Tclass tag to L4
Definition: socket.h:1105
bool IsIpRecvTos(void) const
Ask if the socket is currently passing information about IP Type of Service up the stack.
Definition: socket.cc:465
void NotifyDataRecv(void)
Notify through the callback (if set) that some data have been received.
Definition: socket.cc:305
virtual bool GetAllowBroadcast() const =0
Query whether broadcast datagram transmissions are allowed.
Ipv6MulticastFilterMode
Enumeration of the possible filter of a socket.
Definition: socket.h:139
Ptr< NetDevice > m_boundnetdevice
the device this socket is bound to (might be null).
Definition: socket.h:1077
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
virtual void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
Definition: socket.cc:330
SocketPriority
Enumeration of the possible socket priorities.
Definition: socket.h:118
@ NS3_PRIO_BULK
Definition: socket.h:121
@ NS3_PRIO_BESTEFFORT
Definition: socket.h:119
@ NS3_PRIO_INTERACTIVE
Definition: socket.h:123
@ NS3_PRIO_FILLER
Definition: socket.h:120
@ NS3_PRIO_CONTROL
Definition: socket.h:124
@ NS3_PRIO_INTERACTIVE_BULK
Definition: socket.h:122
void NotifyErrorClose(void)
Notify through the callback (if set) that the connection has been closed due to an error.
Definition: socket.cc:247
virtual uint8_t GetIpTtl(void) const
Query the value of IP Time to Live field of this socket.
Definition: socket.cc:520
bool m_ipRecvTtl
socket forwards IPv4 TTL tag to L4
Definition: socket.h:1097
virtual int GetSockName(Address &address) const =0
Get socket address.
virtual void Ipv6JoinGroup(Ipv6Address address, Ipv6MulticastFilterMode filterMode, std::vector< Ipv6Address > sourceAddresses)
Joins a IPv6 multicast group.
Definition: socket.cc:563
Callback< void, Ptr< Socket > > m_receivedData
data received callback
Definition: socket.h:1090
virtual uint8_t GetIpv6HopLimit(void) const
Query the value of IP Hop Limit field of this socket.
Definition: socket.cc:545
virtual Ptr< Node > GetNode(void) const =0
Return the node this socket is associated with.
virtual int Close(void)=0
Close a socket.
void SetCloseCallbacks(Callback< void, Ptr< Socket > > normalClose, Callback< void, Ptr< Socket > > errorClose)
Detect socket recv() events such as graceful shutdown or error.
Definition: socket.cc:94
Callback< void, Ptr< Socket >, uint32_t > m_sendCb
packet sent callback
Definition: socket.h:1089
bool m_manualIpv6Tclass
socket has IPv6 Tclass set
Definition: socket.h:1103
Callback< void, Ptr< Socket >, const Address & > m_newConnectionCreated
connection created callback
Definition: socket.h:1087
bool m_manualIpTtl
socket has IPv4 TTL set
Definition: socket.h:1095
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
Definition: socket.cc:128
virtual uint32_t GetRxAvailable(void) const =0
Return number of bytes which can be returned from one or multiple calls to Recv.
bool IsManualIpv6Tclass(void) const
Checks if the socket has a specific IPv6 Tclass set.
Definition: socket.cc:371
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
Definition: socket.cc:71
Callback< void, Ptr< Socket >, uint32_t > m_dataSent
data sent callback
Definition: socket.h:1088
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition: socket.h:82
@ ERROR_NOROUTETOHOST
Definition: socket.h:93
@ SOCKET_ERRNO_LAST
Definition: socket.h:97
@ ERROR_SHUTDOWN
Definition: socket.h:88
@ ERROR_INVAL
Definition: socket.h:91
@ ERROR_ADDRINUSE
Definition: socket.h:96
@ ERROR_AGAIN
Definition: socket.h:87
@ ERROR_OPNOTSUPP
Definition: socket.h:89
@ ERROR_AFNOSUPPORT
Definition: socket.h:90
@ ERROR_BADF
Definition: socket.h:92
@ ERROR_NOTERROR
Definition: socket.h:83
@ ERROR_ISCONN
Definition: socket.h:84
@ ERROR_NODEV
Definition: socket.h:94
@ ERROR_ADDRNOTAVAIL
Definition: socket.h:95
@ ERROR_NOTCONN
Definition: socket.h:85
@ ERROR_MSGSIZE
Definition: socket.h:86
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
void SetIpv6RecvHopLimit(bool ipv6RecvHopLimit)
Tells a socket to pass information about IPv6 Hop Limit up the stack.
Definition: socket.cc:551
void SetIpv6Tclass(int ipTclass)
Manually set IPv6 Traffic Class field.
Definition: socket.cc:471
void NotifyDataSent(uint32_t size)
Notify through the callback (if set) that some data have been sent.
Definition: socket.cc:285
virtual enum Socket::SocketErrno GetErrno(void) const =0
Get last error number.
virtual uint32_t GetTxAvailable(void) const =0
Returns the number of bytes which can be sent in a single call to Send.
void SetIpRecvTtl(bool ipv4RecvTtl)
Tells a socket to pass information about IP_TTL up the stack.
Definition: socket.cc:526
void SetIpv6RecvTclass(bool ipv6RecvTclass)
Tells a socket to pass information about IPv6 Traffic Class up the stack.
Definition: socket.cc:501
uint8_t GetIpTos(void) const
Query the value of IP Type of Service of this socket.
Definition: socket.cc:453
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)=0
Read a single packet from the socket and retrieve the sender address.
virtual void Ipv6LeaveGroup(void)
Leaves IPv6 multicast group this socket is joined to.
Definition: socket.cc:580
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
virtual enum Socket::SocketType GetSocketType(void) const =0
Callback< bool, Ptr< Socket >, const Address & > m_connectionRequest
connection request callback
Definition: socket.h:1086
Ptr< Packet > Recv(void)
Read a single packet from the socket.
Definition: socket.cc:175
Callback< void, Ptr< Socket > > m_errorClose
connection closed due to errors callback
Definition: socket.h:1085
indicates whether the socket has IP_TOS set.
Definition: socket.h:1263
uint8_t m_ipTos
the TOS carried by the tag
Definition: socket.h:1302
virtual uint32_t GetSerializedSize(void) const
Definition: socket.cc:814
virtual void Serialize(TagBuffer i) const
Definition: socket.cc:820
void SetTos(uint8_t tos)
Set the tag's TOS.
Definition: socket.cc:785
static TypeId GetTypeId(void)
Get the type ID.
Definition: socket.cc:797
virtual void Deserialize(TagBuffer i)
Definition: socket.cc:826
uint8_t GetTos(void) const
Get the tag's TOS.
Definition: socket.cc:791
virtual void Print(std::ostream &os) const
Definition: socket.cc:831
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition: socket.cc:808
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer.
Definition: socket.h:1117
static TypeId GetTypeId(void)
Get the type ID.
Definition: socket.cc:620
virtual void Deserialize(TagBuffer i)
Definition: socket.cc:648
uint8_t GetTtl(void) const
Get the tag's TTL.
Definition: socket.cc:611
void SetTtl(uint8_t ttl)
Set the tag's TTL.
Definition: socket.cc:604
virtual void Print(std::ostream &os) const
Definition: socket.cc:654
virtual uint32_t GetSerializedSize(void) const
Definition: socket.cc:636
uint8_t m_ttl
the ttl carried by the tag
Definition: socket.h:1157
virtual void Serialize(TagBuffer i) const
Definition: socket.cc:642
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition: socket.cc:630
This class implements a tag that carries the socket-specific HOPLIMIT of a packet to the IPv6 layer.
Definition: socket.h:1165
virtual void Deserialize(TagBuffer i)
Definition: socket.cc:705
static TypeId GetTypeId(void)
Get the type ID.
Definition: socket.cc:679
virtual void Serialize(TagBuffer i) const
Definition: socket.cc:700
virtual void Print(std::ostream &os) const
Definition: socket.cc:710
void SetHopLimit(uint8_t hopLimit)
Set the tag's Hop Limit.
Definition: socket.cc:665
uint8_t GetHopLimit(void) const
Get the tag's Hop Limit.
Definition: socket.cc:671
virtual uint32_t GetSerializedSize(void) const
Definition: socket.cc:695
uint8_t m_hopLimit
the Hop Limit carried by the tag
Definition: socket.h:1205
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition: socket.cc:689
indicates whether the socket has IPV6_TCLASS set.
Definition: socket.h:1356
uint8_t GetTclass(void) const
Get the tag's Tclass.
Definition: socket.cc:906
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition: socket.cc:923
virtual uint32_t GetSerializedSize(void) const
Definition: socket.cc:929
virtual void Deserialize(TagBuffer i)
Definition: socket.cc:941
static TypeId GetTypeId(void)
Get the type ID.
Definition: socket.cc:912
uint8_t m_ipv6Tclass
the Tclass carried by the tag
Definition: socket.h:1395
virtual void Serialize(TagBuffer i) const
Definition: socket.cc:935
virtual void Print(std::ostream &os) const
Definition: socket.cc:946
void SetTclass(uint8_t tclass)
Set the tag's Tclass.
Definition: socket.cc:900
indicates whether the socket has a priority set.
Definition: socket.h:1309
uint8_t m_priority
the priority carried by the tag
Definition: socket.h:1348
uint8_t GetPriority(void) const
Get the tag's priority.
Definition: socket.cc:848
virtual void Serialize(TagBuffer i) const
Definition: socket.cc:877
virtual void Deserialize(TagBuffer i)
Definition: socket.cc:883
virtual uint32_t GetSerializedSize(void) const
Definition: socket.cc:871
static TypeId GetTypeId(void)
Get the type ID.
Definition: socket.cc:854
virtual void Print(std::ostream &os) const
Definition: socket.cc:889
void SetPriority(uint8_t priority)
Set the tag's priority.
Definition: socket.cc:842
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition: socket.cc:865
indicates whether packets should be sent out with the DF (Don't Fragment) flag set.
Definition: socket.h:1213
bool IsEnabled(void) const
Checks if the DF (Don't Fragment) flag is set.
Definition: socket.cc:732
virtual void Serialize(TagBuffer i) const
Definition: socket.cc:761
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition: socket.cc:750
void Disable(void)
Disables the DF (Don't Fragment) flag.
Definition: socket.cc:726
virtual void Print(std::ostream &os) const
Definition: socket.cc:773
static TypeId GetTypeId(void)
Get the type ID.
Definition: socket.cc:741
virtual void Deserialize(TagBuffer i)
Definition: socket.cc:767
bool m_dontFragment
DF bit value for outgoing packets.
Definition: socket.h:1255
void Enable(void)
Enables the DF (Don't Fragment) flag.
Definition: socket.cc:720
virtual uint32_t GetSerializedSize(void) const
Definition: socket.cc:755
read and write tag data
Definition: tag-buffer.h:52
tag a set of bytes in a packet
Definition: tag.h:37
a unique identifier for an interface.
Definition: type-id.h:59
address
Definition: first.py:44
Every class exported by the ns3 library is enclosed in the ns3 namespace.