A Discrete-Event Network Simulator
API
socket.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2006 Georgia Tech Research Corporation
3  * 2007 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Authors: George F. Riley<riley@ece.gatech.edu>
19  * Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  */
21 
22 #ifndef NS3_SOCKET_H
23 #define NS3_SOCKET_H
24 
25 #include "address.h"
26 #include "net-device.h"
27 #include "tag.h"
28 
29 #include "ns3/callback.h"
30 #include "ns3/inet-socket-address.h"
31 #include "ns3/inet6-socket-address.h"
32 #include "ns3/object.h"
33 #include "ns3/ptr.h"
34 
35 #include <stdint.h>
36 
37 namespace ns3
38 {
39 
40 class Node;
41 class Packet;
42 
67 class Socket : public Object
68 {
69  public:
74  static TypeId GetTypeId();
75 
76  Socket();
77  ~Socket() override;
78 
84  {
100  };
101 
107  {
112  };
113 
122  {
128  NS3_PRIO_CONTROL = 7
129  };
130 
143  {
144  INCLUDE = 1,
145  EXCLUDE
146  };
147 
157  static Ptr<Socket> CreateSocket(Ptr<Node> node, TypeId tid);
165  virtual Socket::SocketErrno GetErrno() const = 0;
169  virtual Socket::SocketType GetSocketType() const = 0;
174  virtual Ptr<Node> GetNode() const = 0;
187  void SetConnectCallback(Callback<void, Ptr<Socket>> connectionSucceeded,
188  Callback<void, Ptr<Socket>> connectionFailed);
204  void SetCloseCallbacks(Callback<void, Ptr<Socket>> normalClose,
205  Callback<void, Ptr<Socket>> errorClose);
223  void SetAcceptCallback(Callback<bool, Ptr<Socket>, const Address&> connectionRequest,
224  Callback<void, Ptr<Socket>, const Address&> newConnectionCreated);
232  void SetDataSentCallback(Callback<void, Ptr<Socket>, uint32_t> dataSent);
247  void SetSendCallback(Callback<void, Ptr<Socket>, uint32_t> sendCb);
258  void SetRecvCallback(Callback<void, Ptr<Socket>> receivedData);
264  virtual int Bind(const Address& address) = 0;
265 
271  virtual int Bind() = 0;
272 
278  virtual int Bind6() = 0;
279 
287  virtual int Close() = 0;
288 
295  virtual int ShutdownSend() = 0;
296 
303  virtual int ShutdownRecv() = 0;
304 
310  virtual int Connect(const Address& address) = 0;
311 
316  virtual int Listen() = 0;
317 
330  virtual uint32_t GetTxAvailable() const = 0;
331 
377  virtual int Send(Ptr<Packet> p, uint32_t flags) = 0;
378 
392  virtual int SendTo(Ptr<Packet> p, uint32_t flags, const Address& toAddress) = 0;
393 
402  virtual uint32_t GetRxAvailable() 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, Address& fromAddress) = 0;
477 
479  // The remainder of these public methods are overloaded methods //
480  // or variants of Send() and Recv(), and they are non-virtual //
482 
492  int Send(Ptr<Packet> p);
493 
508  int Send(const uint8_t* buf, uint32_t size, uint32_t flags);
509 
526  int SendTo(const uint8_t* buf, uint32_t size, uint32_t flags, const Address& address);
527 
537  Ptr<Packet> Recv();
538 
553  int Recv(uint8_t* buf, uint32_t size, uint32_t flags);
554 
568  Ptr<Packet> RecvFrom(Address& fromAddress);
569 
587  int RecvFrom(uint8_t* buf, uint32_t size, uint32_t flags, Address& fromAddress);
593  virtual int GetSockName(Address& address) const = 0;
594 
600  virtual int GetPeerName(Address& address) const = 0;
601 
620  virtual void BindToNetDevice(Ptr<NetDevice> netdevice);
621 
632 
644  virtual bool SetAllowBroadcast(bool allowBroadcast) = 0;
645 
654  virtual bool GetAllowBroadcast() const = 0;
655 
667  void SetRecvPktInfo(bool flag);
668 
674  bool IsRecvPktInfo() const;
675 
688  void SetPriority(uint8_t priority);
689 
698  uint8_t GetPriority() const;
699 
776  static uint8_t IpTos2Priority(uint8_t ipTos);
777 
788  void SetIpTos(uint8_t ipTos);
789 
798  uint8_t GetIpTos() const;
799 
811  void SetIpRecvTos(bool ipv4RecvTos);
812 
822  bool IsIpRecvTos() const;
823 
834  void SetIpv6Tclass(int ipTclass);
835 
844  uint8_t GetIpv6Tclass() const;
845 
857  void SetIpv6RecvTclass(bool ipv6RecvTclass);
858 
868  bool IsIpv6RecvTclass() const;
869 
878  virtual void SetIpTtl(uint8_t ipTtl);
879 
888  virtual uint8_t GetIpTtl() const;
889 
901  void SetIpRecvTtl(bool ipv4RecvTtl);
902 
911  bool IsIpRecvTtl() const;
912 
921  virtual void SetIpv6HopLimit(uint8_t ipHopLimit);
922 
931  virtual uint8_t GetIpv6HopLimit() const;
932 
944  void SetIpv6RecvHopLimit(bool ipv6RecvHopLimit);
945 
954  bool IsIpv6RecvHopLimit() const;
955 
971  virtual void Ipv6JoinGroup(Ipv6Address address,
972  Ipv6MulticastFilterMode filterMode,
973  std::vector<Ipv6Address> sourceAddresses);
974 
983  virtual void Ipv6JoinGroup(Ipv6Address address);
984 
988  virtual void Ipv6LeaveGroup();
989 
990  protected:
996 
1001  void NotifyConnectionFailed();
1002 
1007  void NotifyNormalClose();
1008 
1013  void NotifyErrorClose();
1014 
1026  bool NotifyConnectionRequest(const Address& from);
1027 
1034  void NotifyNewConnectionCreated(Ptr<Socket> socket, const Address& from);
1035 
1041  void NotifyDataSent(uint32_t size);
1042 
1048  void NotifySend(uint32_t spaceAvailable);
1049 
1053  void NotifyDataRecv();
1054 
1055  // inherited function, no doc necessary
1056  void DoDispose() override;
1057 
1063  bool IsManualIpv6Tclass() const;
1064 
1070  bool IsManualIpTtl() const;
1071 
1077  bool IsManualIpv6HopLimit() const;
1078 
1080  bool
1083 
1084  private:
1096 
1097  uint8_t m_priority;
1098 
1099  // IPv4 options
1103 
1104  uint8_t m_ipTos;
1105  uint8_t m_ipTtl;
1106 
1107  // IPv6 options
1112 
1113  uint8_t m_ipv6Tclass;
1114  uint8_t m_ipv6HopLimit;
1115 };
1116 
1121 class SocketIpTtlTag : public Tag
1122 {
1123  public:
1124  SocketIpTtlTag();
1125 
1131  void SetTtl(uint8_t ttl);
1132 
1138  uint8_t GetTtl() const;
1139 
1144  static TypeId GetTypeId();
1145 
1146  // inherited function, no need to doc.
1147  TypeId GetInstanceTypeId() const override;
1148 
1149  // inherited function, no need to doc.
1150  uint32_t GetSerializedSize() const override;
1151 
1152  // inherited function, no need to doc.
1153  void Serialize(TagBuffer i) const override;
1154 
1155  // inherited function, no need to doc.
1156  void Deserialize(TagBuffer i) override;
1157 
1158  // inherited function, no need to doc.
1159  void Print(std::ostream& os) const override;
1160 
1161  private:
1162  uint8_t m_ttl;
1163 };
1164 
1170 {
1171  public:
1173 
1179  void SetHopLimit(uint8_t hopLimit);
1180 
1186  uint8_t GetHopLimit() const;
1187 
1192  static TypeId GetTypeId();
1193 
1194  // inherited function, no need to doc.
1195  TypeId GetInstanceTypeId() const override;
1196 
1197  // inherited function, no need to doc.
1198  uint32_t GetSerializedSize() const override;
1199 
1200  // inherited function, no need to doc.
1201  void Serialize(TagBuffer i) const override;
1202 
1203  // inherited function, no need to doc.
1204  void Deserialize(TagBuffer i) override;
1205 
1206  // inherited function, no need to doc.
1207  void Print(std::ostream& os) const override;
1208 
1209  private:
1210  uint8_t m_hopLimit;
1211 };
1212 
1218 {
1219  public:
1221 
1225  void Enable();
1226 
1230  void Disable();
1231 
1237  bool IsEnabled() const;
1238 
1243  static TypeId GetTypeId();
1244 
1245  // inherited function, no need to doc.
1246  TypeId GetInstanceTypeId() const override;
1247 
1248  // inherited function, no need to doc.
1249  uint32_t GetSerializedSize() const override;
1250 
1251  // inherited function, no need to doc.
1252  void Serialize(TagBuffer i) const override;
1253 
1254  // inherited function, no need to doc.
1255  void Deserialize(TagBuffer i) override;
1256 
1257  // inherited function, no need to doc.
1258  void Print(std::ostream& os) const override;
1259 
1260  private:
1262 };
1263 
1268 class SocketIpTosTag : public Tag
1269 {
1270  public:
1271  SocketIpTosTag();
1272 
1278  void SetTos(uint8_t tos);
1279 
1285  uint8_t GetTos() const;
1286 
1291  static TypeId GetTypeId();
1292 
1293  // inherited function, no need to doc.
1294  TypeId GetInstanceTypeId() const override;
1295 
1296  // inherited function, no need to doc.
1297  uint32_t GetSerializedSize() const override;
1298 
1299  // inherited function, no need to doc.
1300  void Serialize(TagBuffer i) const override;
1301 
1302  // inherited function, no need to doc.
1303  void Deserialize(TagBuffer i) override;
1304 
1305  // inherited function, no need to doc.
1306  void Print(std::ostream& os) const override;
1307 
1308  private:
1309  uint8_t m_ipTos;
1310 };
1311 
1315 class SocketPriorityTag : public Tag
1316 {
1317  public:
1319 
1325  void SetPriority(uint8_t priority);
1326 
1332  uint8_t GetPriority() const;
1333 
1338  static TypeId GetTypeId();
1339 
1340  // inherited function, no need to doc.
1341  TypeId GetInstanceTypeId() const override;
1342 
1343  // inherited function, no need to doc.
1344  uint32_t GetSerializedSize() const override;
1345 
1346  // inherited function, no need to doc.
1347  void Serialize(TagBuffer i) const override;
1348 
1349  // inherited function, no need to doc.
1350  void Deserialize(TagBuffer i) override;
1351 
1352  // inherited function, no need to doc.
1353  void Print(std::ostream& os) const override;
1354 
1355  private:
1356  uint8_t m_priority;
1357 };
1358 
1363 class SocketIpv6TclassTag : public Tag
1364 {
1365  public:
1367 
1373  void SetTclass(uint8_t tclass);
1374 
1380  uint8_t GetTclass() const;
1381 
1386  static TypeId GetTypeId();
1387 
1388  // inherited function, no need to doc.
1389  TypeId GetInstanceTypeId() const override;
1390 
1391  // inherited function, no need to doc.
1392  uint32_t GetSerializedSize() const override;
1393 
1394  // inherited function, no need to doc.
1395  void Serialize(TagBuffer i) const override;
1396 
1397  // inherited function, no need to doc.
1398  void Deserialize(TagBuffer i) override;
1399 
1400  // inherited function, no need to doc.
1401  void Print(std::ostream& os) const override;
1402 
1403  private:
1404  uint8_t m_ipv6Tclass;
1405 };
1406 
1407 } // namespace ns3
1408 
1409 #endif /* NS3_SOCKET_H */
a polymophic address class
Definition: address.h:101
Callback template class.
Definition: callback.h:438
Describes an IPv6 address.
Definition: ipv6-address.h:49
A base class which provides memory management and object aggregation.
Definition: object.h:89
A low-level Socket API based loosely on the BSD Socket API.
Definition: socket.h:68
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:347
bool IsIpRecvTtl() const
Ask if the socket is currently passing information about IP_TTL up the stack.
Definition: socket.cc:529
virtual void SetIpTtl(uint8_t ipTtl)
Manually set IP Time to Live field.
Definition: socket.cc:510
virtual Socket::SocketType GetSocketType() const =0
Ptr< Packet > Recv()
Read a single packet from the socket.
Definition: socket.cc:174
Callback< void, Ptr< Socket > > m_normalClose
connection closed callback
Definition: socket.h:1087
virtual void Ipv6LeaveGroup()
Leaves IPv6 multicast group this socket is joined to.
Definition: socket.cc:580
bool m_ipv6RecvHopLimit
socket forwards IPv6 Hop Limit tag to L4
Definition: socket.h:1111
uint8_t m_ipTos
the socket IPv4 TOS
Definition: socket.h:1104
uint8_t m_priority
the socket priority
Definition: socket.h:1097
virtual Socket::SocketErrno GetErrno() const =0
Get last error number.
bool IsManualIpTtl() const
Checks if the socket has a specific IPv4 TTL set.
Definition: socket.cc:374
void SetIpTos(uint8_t ipTos)
Manually set IP Type of Service field.
Definition: socket.cc:434
bool m_manualIpv6HopLimit
socket has IPv6 Hop Limit set
Definition: socket.h:1109
Callback< bool, Ptr< Socket >, const Address & > m_connectionRequest
connection request callback
Definition: socket.h:1090
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:354
void NotifySend(uint32_t spaceAvailable)
Notify through the callback (if set) that some data have been sent.
Definition: socket.cc:292
void NotifyNewConnectionCreated(Ptr< Socket > socket, const Address &from)
Notify through the callback (if set) that a new connection has been created.
Definition: socket.cc:272
virtual uint8_t GetIpTtl() const
Query the value of IP Time to Live field of this socket.
Definition: socket.cc:517
Callback< void, Ptr< Socket > > m_connectionFailed
connection failed callback
Definition: socket.h:1086
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:96
static TypeId GetTypeId()
Get the type ID.
Definition: socket.cc:40
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:105
bool IsRecvPktInfo() const
Get status indicating whether enable/disable packet information to socket.
Definition: socket.cc:361
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:254
uint8_t m_ipTtl
the socket IPv4 TTL
Definition: socket.h:1105
uint8_t m_ipv6HopLimit
the socket IPv6 Hop Limit
Definition: socket.h:1114
uint8_t GetIpTos() const
Query the value of IP Type of Service of this socket.
Definition: socket.cc:450
~Socket() override
Definition: socket.cc:66
virtual uint32_t GetRxAvailable() const =0
Return number of bytes which can be returned from one or multiple calls to Recv.
void SetIpRecvTos(bool ipv4RecvTos)
Tells a socket to pass information about IP Type of Service up the stack.
Definition: socket.cc:456
void SetRecvCallback(Callback< void, Ptr< Socket >> receivedData)
Notify application when new data is available to be read.
Definition: socket.cc:128
Ipv6Address m_ipv6MulticastGroupAddress
IPv6 multicast group address.
Definition: socket.h:1082
virtual int ShutdownRecv()=0
bool m_ipRecvTos
socket forwards IPv4 TOS tag to L4
Definition: socket.h:1101
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:107
@ NS3_SOCK_STREAM
Definition: socket.h:108
@ NS3_SOCK_DGRAM
Definition: socket.h:110
@ NS3_SOCK_SEQPACKET
Definition: socket.h:109
@ NS3_SOCK_RAW
Definition: socket.h:111
virtual void SetIpv6HopLimit(uint8_t ipHopLimit)
Manually set IPv6 Hop Limit.
Definition: socket.cc:535
uint8_t m_ipv6Tclass
the socket IPv6 Tclass
Definition: socket.h:1113
bool m_recvPktInfo
if the socket should add packet info tags to the packet forwarded to L4.
Definition: socket.h:1081
Callback< void, Ptr< Socket > > m_connectionSucceeded
connection succeeded callback
Definition: socket.h:1085
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.
virtual int ShutdownSend()=0
static uint8_t IpTos2Priority(uint8_t ipTos)
Return the priority corresponding to a given TOS value.
Definition: socket.cc:399
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.
void NotifyErrorClose()
Notify through the callback (if set) that the connection has been closed due to an error.
Definition: socket.cc:244
void NotifyDataRecv()
Notify through the callback (if set) that some data have been received.
Definition: socket.cc:302
void SetPriority(uint8_t priority)
Manually set the socket priority.
Definition: socket.cc:386
bool m_ipv6RecvTclass
socket forwards IPv6 Tclass tag to L4
Definition: socket.h:1110
virtual bool GetAllowBroadcast() const =0
Query whether broadcast datagram transmissions are allowed.
Ipv6MulticastFilterMode
Enumeration of the possible filter of a socket.
Definition: socket.h:143
Ptr< NetDevice > m_boundnetdevice
the device this socket is bound to (might be null).
Definition: socket.h:1079
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
virtual Ptr< Node > GetNode() const =0
Return the node this socket is associated with.
virtual void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
Definition: socket.cc:327
SocketPriority
Enumeration of the possible socket priorities.
Definition: socket.h:122
@ NS3_PRIO_BULK
Definition: socket.h:125
@ NS3_PRIO_BESTEFFORT
Definition: socket.h:123
@ NS3_PRIO_INTERACTIVE
Definition: socket.h:127
@ NS3_PRIO_FILLER
Definition: socket.h:124
@ NS3_PRIO_CONTROL
Definition: socket.h:128
@ NS3_PRIO_INTERACTIVE_BULK
Definition: socket.h:126
bool m_ipRecvTtl
socket forwards IPv4 TTL tag to L4
Definition: socket.h:1102
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:560
Callback< void, Ptr< Socket > > m_receivedData
data received callback
Definition: socket.h:1095
void NotifyNormalClose()
Notify through the callback (if set) that the connection has been closed.
Definition: socket.cc:234
bool IsIpv6RecvTclass() const
Ask if the socket is currently passing information about IPv6 Traffic Class up the stack.
Definition: socket.cc:504
bool IsIpv6RecvHopLimit() const
Ask if the socket is currently passing information about IPv6 Hop Limit up the stack.
Definition: socket.cc:554
virtual uint8_t GetIpv6HopLimit() const
Query the value of IP Hop Limit field of this socket.
Definition: socket.cc:542
bool m_manualIpv6Tclass
socket has IPv6 Tclass set
Definition: socket.h:1108
Callback< void, Ptr< Socket >, const Address & > m_newConnectionCreated
connection created callback
Definition: socket.h:1092
bool m_manualIpTtl
socket has IPv4 TTL set
Definition: socket.h:1100
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:72
Callback< void, Ptr< Socket >, uint32_t > m_dataSent
data sent callback
Definition: socket.h:1093
virtual int Close()=0
Close a socket.
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition: socket.h:84
@ ERROR_NOROUTETOHOST
Definition: socket.h:95
@ SOCKET_ERRNO_LAST
Definition: socket.h:99
@ ERROR_SHUTDOWN
Definition: socket.h:90
@ ERROR_INVAL
Definition: socket.h:93
@ ERROR_ADDRINUSE
Definition: socket.h:98
@ ERROR_AGAIN
Definition: socket.h:89
@ ERROR_OPNOTSUPP
Definition: socket.h:91
@ ERROR_AFNOSUPPORT
Definition: socket.h:92
@ ERROR_BADF
Definition: socket.h:94
@ ERROR_NOTERROR
Definition: socket.h:85
@ ERROR_ISCONN
Definition: socket.h:86
@ ERROR_NODEV
Definition: socket.h:96
@ ERROR_ADDRNOTAVAIL
Definition: socket.h:97
@ ERROR_NOTCONN
Definition: socket.h:87
@ ERROR_MSGSIZE
Definition: socket.h:88
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
bool IsIpRecvTos() const
Ask if the socket is currently passing information about IP Type of Service up the stack.
Definition: socket.cc:462
Callback< void, Ptr< Socket >, uint32_t > m_sendCb
packet sent callback
Definition: socket.h:1094
void SetIpv6RecvHopLimit(bool ipv6RecvHopLimit)
Tells a socket to pass information about IPv6 Hop Limit up the stack.
Definition: socket.cc:548
void SetIpv6Tclass(int ipTclass)
Manually set IPv6 Traffic Class field.
Definition: socket.cc:468
virtual int Listen()=0
Listen for incoming connections.
void NotifyDataSent(uint32_t size)
Notify through the callback (if set) that some data have been sent.
Definition: socket.cc:282
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:87
void NotifyConnectionSucceeded()
Notify through the callback (if set) that the connection has been established.
Definition: socket.cc:214
virtual uint32_t GetTxAvailable() 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:523
uint8_t GetPriority() const
Query the priority value of this socket.
Definition: socket.cc:393
void SetIpv6RecvTclass(bool ipv6RecvTclass)
Tells a socket to pass information about IPv6 Traffic Class up the stack.
Definition: socket.cc:498
void DoDispose() override
Destructor implementation.
Definition: socket.cc:312
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.
uint8_t GetIpv6Tclass() const
Query the value of IPv6 Traffic Class field of this socket.
Definition: socket.cc:492
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
bool IsManualIpv6HopLimit() const
Checks if the socket has a specific IPv6 Hop Limit set.
Definition: socket.cc:380
Callback< void, Ptr< Socket > > m_errorClose
connection closed due to errors callback
Definition: socket.h:1088
bool IsManualIpv6Tclass() const
Checks if the socket has a specific IPv6 Tclass set.
Definition: socket.cc:368
void NotifyConnectionFailed()
Notify through the callback (if set) that the connection has not been established due to an error.
Definition: socket.cc:224
indicates whether the socket has IP_TOS set.
Definition: socket.h:1269
uint8_t m_ipTos
the TOS carried by the tag
Definition: socket.h:1309
void Serialize(TagBuffer i) const override
Definition: socket.cc:832
static TypeId GetTypeId()
Get the type ID.
Definition: socket.cc:810
uint32_t GetSerializedSize() const override
Definition: socket.cc:826
void SetTos(uint8_t tos)
Set the tag's TOS.
Definition: socket.cc:798
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition: socket.cc:820
uint8_t GetTos() const
Get the tag's TOS.
Definition: socket.cc:804
void Print(std::ostream &os) const override
Definition: socket.cc:844
void Deserialize(TagBuffer i) override
Definition: socket.cc:838
This class implements a tag that carries the socket-specific TTL of a packet to the IP layer.
Definition: socket.h:1122
void SetTtl(uint8_t ttl)
Set the tag's TTL.
Definition: socket.cc:604
void Deserialize(TagBuffer i) override
Definition: socket.cc:650
uint32_t GetSerializedSize() const override
Definition: socket.cc:636
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition: socket.cc:630
void Serialize(TagBuffer i) const override
Definition: socket.cc:643
uint8_t GetTtl() const
Get the tag's TTL.
Definition: socket.cc:611
uint8_t m_ttl
the ttl carried by the tag
Definition: socket.h:1162
static TypeId GetTypeId()
Get the type ID.
Definition: socket.cc:620
void Print(std::ostream &os) const override
Definition: socket.cc:657
This class implements a tag that carries the socket-specific HOPLIMIT of a packet to the IPv6 layer.
Definition: socket.h:1170
uint32_t GetSerializedSize() const override
Definition: socket.cc:698
uint8_t GetHopLimit() const
Get the tag's Hop Limit.
Definition: socket.cc:674
static TypeId GetTypeId()
Get the type ID.
Definition: socket.cc:682
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition: socket.cc:692
void Serialize(TagBuffer i) const override
Definition: socket.cc:704
void SetHopLimit(uint8_t hopLimit)
Set the tag's Hop Limit.
Definition: socket.cc:668
void Print(std::ostream &os) const override
Definition: socket.cc:716
uint8_t m_hopLimit
the Hop Limit carried by the tag
Definition: socket.h:1210
void Deserialize(TagBuffer i) override
Definition: socket.cc:710
indicates whether the socket has IPV6_TCLASS set.
Definition: socket.h:1364
void Serialize(TagBuffer i) const override
Definition: socket.cc:944
void Print(std::ostream &os) const override
Definition: socket.cc:956
uint8_t GetTclass() const
Get the tag's Tclass.
Definition: socket.cc:916
uint32_t GetSerializedSize() const override
Definition: socket.cc:938
static TypeId GetTypeId()
Get the type ID.
Definition: socket.cc:922
uint8_t m_ipv6Tclass
the Tclass carried by the tag
Definition: socket.h:1404
void Deserialize(TagBuffer i) override
Definition: socket.cc:950
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition: socket.cc:932
void SetTclass(uint8_t tclass)
Set the tag's Tclass.
Definition: socket.cc:910
indicates whether the socket has a priority set.
Definition: socket.h:1316
uint8_t m_priority
the priority carried by the tag
Definition: socket.h:1356
void Print(std::ostream &os) const override
Definition: socket.cc:900
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition: socket.cc:876
uint32_t GetSerializedSize() const override
Definition: socket.cc:882
void Deserialize(TagBuffer i) override
Definition: socket.cc:894
static TypeId GetTypeId()
Get the type ID.
Definition: socket.cc:866
uint8_t GetPriority() const
Get the tag's priority.
Definition: socket.cc:860
void SetPriority(uint8_t priority)
Set the tag's priority.
Definition: socket.cc:854
void Serialize(TagBuffer i) const override
Definition: socket.cc:888
indicates whether packets should be sent out with the DF (Don't Fragment) flag set.
Definition: socket.h:1218
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition: socket.cc:760
static TypeId GetTypeId()
Get the type ID.
Definition: socket.cc:750
void Enable()
Enables the DF (Don't Fragment) flag.
Definition: socket.cc:727
void Deserialize(TagBuffer i) override
Definition: socket.cc:780
uint32_t GetSerializedSize() const override
Definition: socket.cc:766
void Print(std::ostream &os) const override
Definition: socket.cc:787
void Serialize(TagBuffer i) const override
Definition: socket.cc:773
bool m_dontFragment
DF bit value for outgoing packets.
Definition: socket.h:1261
bool IsEnabled() const
Checks if the DF (Don't Fragment) flag is set.
Definition: socket.cc:741
void Disable()
Disables the DF (Don't Fragment) flag.
Definition: socket.cc:734
read and write tag data
Definition: tag-buffer.h:52
tag a set of bytes in a packet
Definition: tag.h:39
a unique identifier for an interface.
Definition: type-id.h:59
address
Definition: first.py:47
Every class exported by the ns3 library is enclosed in the ns3 namespace.