PageRenderTime 42ms CodeModel.GetById 12ms app.highlight 22ms RepoModel.GetById 1ms app.codeStats 0ms

/src/network/model/socket.h

https://bitbucket.org/nsnam/ns-3-dev
C++ Header | 1395 lines | 260 code | 144 blank | 991 comment | 0 complexity | 6fe919ccd43df227417576ef0f956d9e MD5 | raw 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
  36namespace ns3 {
  37
  38
  39class Node;
  40class Packet;
  41
  42/**
  43 * \ingroup network
  44 * \defgroup socket Socket
  45 */
  46
  47/**
  48 * \brief A low-level Socket API based loosely on the BSD Socket API.
  49 * \ingroup socket
  50 *
  51 * A few things to keep in mind about this type of socket:
  52 * - it uses ns-3 API constructs such as class ns3::Address instead of
  53 *   C-style structs
  54 * - in contrast to the original BSD socket API, this API is asynchronous:
  55 *   it does not contain blocking calls.  Sending and receiving operations
  56 *   must make use of the callbacks provided. 
  57 * - It also uses class ns3::Packet as a fancy byte buffer, allowing 
  58 *   data to be passed across the API using an ns-3 Packet instead of 
  59 *   a raw data pointer.
  60 * - Not all of the full POSIX sockets API is supported
  61 *
  62 * Other than that, it tries to stick to the BSD API to make it 
  63 * easier for those who know the BSD API to use this API.
  64 * More details are provided in the ns-3 tutorial.
  65 */
  66class Socket : public Object
  67{
  68public:
  69  /**
  70   * \brief Get the type ID.
  71   * \return the object TypeId
  72   */
  73  static TypeId GetTypeId (void);
  74
  75  Socket (void);
  76  virtual ~Socket (void);
  77
  78  /**
  79   * \enum SocketErrno
  80   * \brief Enumeration of the possible errors returned by a socket.
  81   */
  82  enum SocketErrno {
  83    ERROR_NOTERROR,
  84    ERROR_ISCONN,
  85    ERROR_NOTCONN,
  86    ERROR_MSGSIZE,
  87    ERROR_AGAIN,
  88    ERROR_SHUTDOWN,
  89    ERROR_OPNOTSUPP,
  90    ERROR_AFNOSUPPORT,
  91    ERROR_INVAL,
  92    ERROR_BADF,
  93    ERROR_NOROUTETOHOST,
  94    ERROR_NODEV,
  95    ERROR_ADDRNOTAVAIL,
  96    ERROR_ADDRINUSE,
  97    SOCKET_ERRNO_LAST
  98  };
  99
 100  /**
 101   * \enum SocketType
 102   * \brief Enumeration of the possible socket types.
 103   */
 104  enum SocketType {
 105    NS3_SOCK_STREAM,
 106    NS3_SOCK_SEQPACKET,
 107    NS3_SOCK_DGRAM,
 108    NS3_SOCK_RAW
 109  };
 110
 111  /**
 112   * \enum SocketPriority
 113   * \brief Enumeration of the possible socket priorities.
 114   *
 115   * Names and corresponding values are derived from
 116   * the Linux TC_PRIO_* macros
 117   */
 118  enum SocketPriority {
 119    NS3_PRIO_BESTEFFORT = 0,
 120    NS3_PRIO_FILLER = 1,
 121    NS3_PRIO_BULK = 2,
 122    NS3_PRIO_INTERACTIVE_BULK = 4,
 123    NS3_PRIO_INTERACTIVE = 6,
 124    NS3_PRIO_CONTROL = 7
 125  };
 126
 127  /**
 128   * \enum Ipv6MulticastFilterMode
 129   * \brief Enumeration of the possible filter of a socket.
 130   *
 131   * A socket can have filters on specific sources to include only
 132   * packets incoming from them, or to exclude packets incoming
 133   * from specific sources.
 134   * Moreover, inclusion and exclusion also works as a leave,
 135   * since "joining" a group without allowed sources is equivalent
 136   * to leaving it.
 137   */
 138  enum Ipv6MulticastFilterMode
 139  {
 140    INCLUDE=1,
 141    EXCLUDE
 142  };
 143
 144  /**
 145   * This method wraps the creation of sockets that is performed
 146   * on a given node by a SocketFactory specified by TypeId.
 147   * 
 148   * \return A smart pointer to a newly created socket.
 149   * 
 150   * \param node The node on which to create the socket
 151   * \param tid The TypeId of a SocketFactory class to use
 152   */
 153  static Ptr<Socket> CreateSocket (Ptr<Node> node, TypeId tid);
 154  /**
 155   * \brief Get last error number.
 156   *
 157   * \return the errno associated to the last call which failed in this
 158   *         socket. Each socket's errno is initialized to zero
 159   *         when the socket is created.
 160   */
 161  virtual enum Socket::SocketErrno GetErrno (void) const = 0;
 162  /**
 163    * \return the socket type, analogous to getsockopt (SO_TYPE)
 164    */
 165  virtual enum Socket::SocketType GetSocketType (void) const = 0;
 166  /**
 167   * \brief Return the node this socket is associated with.
 168   * \returns the node
 169   */
 170  virtual Ptr<Node> GetNode (void) const = 0;
 171  /**
 172   * \brief Specify callbacks to allow the caller to determine if
 173   * the connection succeeds of fails.
 174   * \param connectionSucceeded this callback is invoked when the 
 175   *        connection request initiated by the user is successfully 
 176   *        completed. The callback is passed  back a pointer to 
 177   *        the same socket object.
 178   * \param connectionFailed this callback is invoked when the 
 179   *        connection request initiated by the user is unsuccessfully 
 180   *        completed. The callback is passed back a pointer to the 
 181   *        same socket object. 
 182   */
 183  void SetConnectCallback (Callback<void, Ptr<Socket> > connectionSucceeded,
 184                           Callback<void,  Ptr<Socket> > connectionFailed);
 185  /**
 186   * \brief Detect socket recv() events such as graceful shutdown or error.
 187   *
 188   * For connection-oriented sockets, the first callback is used to signal
 189   * that the remote side has gracefully shut down the connection, and the
 190   * second callback denotes an error corresponding to cases in which
 191   * a traditional recv() socket call might return -1 (error), such
 192   * as a connection reset.  For datagram sockets, these callbacks may
 193   * never be invoked.
 194   *
 195   * \param normalClose this callback is invoked when the
 196   *        peer closes the connection gracefully
 197   * \param errorClose this callback is invoked when the
 198   *        connection closes abnormally
 199   */
 200  void SetCloseCallbacks (Callback<void, Ptr<Socket> > normalClose,
 201                          Callback<void, Ptr<Socket> > errorClose);
 202  /**
 203   * \brief Accept connection requests from remote hosts
 204   * \param connectionRequest Callback for connection request from peer. 
 205   *        This user callback is passed a pointer to this socket, the 
 206   *        ip address and the port number of the connection originator. 
 207   *        This callback must return true to accept the incoming connection,
 208   *        false otherwise. If the connection is accepted, the 
 209   *        "newConnectionCreated" callback will be invoked later to 
 210   *        give access to the user to the socket created to match 
 211   *        this new connection. If the user does not explicitly 
 212   *        specify this callback, all incoming  connections will be refused.
 213   * \param newConnectionCreated Callback for new connection: when a new
 214   *        is accepted, it is created and the corresponding socket is passed
 215   *        back to the user through this callback. This user callback is 
 216   *        passed a pointer to the new socket, and the ip address and 
 217   *        port number of the connection originator.
 218   */
 219  void SetAcceptCallback (Callback<bool, Ptr<Socket>, 
 220                                   const Address &> connectionRequest,
 221                          Callback<void, Ptr<Socket>, 
 222                                   const Address&> newConnectionCreated);
 223  /**
 224   * \brief Notify application when a packet has been sent from transport 
 225   *        protocol (non-standard socket call)
 226   * \param dataSent Callback for the event that data is sent from the
 227   *        underlying transport protocol.  This callback is passed a
 228   *        pointer to the socket, and the number of bytes sent.
 229   */
 230  void SetDataSentCallback (Callback<void, Ptr<Socket>, 
 231                                     uint32_t> dataSent);
 232  /**
 233   * \brief Notify application when space in transmit buffer is added
 234   *
 235   *        This callback is intended to notify a 
 236   *        socket that would have been blocked in a blocking socket model
 237   *        that space is available in the transmit buffer and that it
 238   *        can call Send() again.
 239   *
 240   * \param sendCb Callback for the event that the socket transmit buffer
 241   *        fill level has decreased.  This callback is passed a pointer to
 242   *        the socket, and the number of bytes available for writing
 243   *        into the buffer (an absolute value).  If there is no transmit
 244   *        buffer limit, a maximum-sized integer is always returned.
 245   */
 246  void SetSendCallback (Callback<void, Ptr<Socket>, uint32_t> sendCb);
 247  /**
 248   * \brief Notify application when new data is available to be read.
 249   *
 250   *        This callback is intended to notify a socket that would
 251   *        have been blocked in a blocking socket model that data
 252   *        is available to be read.
 253   */
 254  void SetRecvCallback (Callback<void, Ptr<Socket> >);
 255  /** 
 256   * \brief Allocate a local endpoint for this socket.
 257   * \param address the address to try to allocate
 258   * \returns 0 on success, -1 on failure.
 259   */
 260  virtual int Bind (const Address &address) = 0;
 261
 262  /** 
 263   * \brief Allocate a local IPv4 endpoint for this socket.
 264   *
 265   * \returns 0 on success, -1 on failure.
 266   */
 267  virtual int Bind () = 0;
 268
 269  /** 
 270   * \brief Allocate a local IPv6 endpoint for this socket.
 271   *
 272   * \returns 0 on success, -1 on failure.
 273   */
 274  virtual int Bind6 () = 0;
 275
 276  /**
 277   * \brief Close a socket.
 278   * \returns zero on success, -1 on failure.
 279   *
 280   * After the Close call, the socket is no longer valid, and cannot
 281   * safely be used for subsequent operations.
 282   */
 283  virtual int Close (void) = 0;
 284
 285  /**
 286   * \returns zero on success, -1 on failure.
 287   *
 288   * Do not allow any further Send calls. This method is typically
 289   * implemented for Tcp sockets by a half close.
 290   */
 291  virtual int ShutdownSend (void) = 0;
 292
 293  /**
 294   * \returns zero on success, -1 on failure.
 295   *
 296   * Do not allow any further Recv calls. This method is typically
 297   * implemented for Tcp sockets by a half close.
 298   */
 299  virtual int ShutdownRecv (void) = 0;
 300
 301  /**
 302   * \brief Initiate a connection to a remote host
 303   * \param address Address of remote.
 304   * \returns 0 on success, -1 on error (in which case errno is set).
 305   */
 306  virtual int Connect (const Address &address) = 0;
 307
 308  /**
 309   * \brief Listen for incoming connections.
 310   * \returns 0 on success, -1 on error (in which case errno is set).
 311   */
 312  virtual int Listen (void) = 0;
 313
 314  /**
 315   * \brief Returns the number of bytes which can be sent in a single call
 316   * to Send. 
 317   * 
 318   * For datagram sockets, this returns the number of bytes that
 319   * can be passed atomically through the underlying protocol.
 320   *
 321   * For stream sockets, this returns the available space in bytes
 322   * left in the transmit buffer.
 323   *
 324   * \returns The number of bytes which can be sent in a single Send call.
 325   */
 326  virtual uint32_t GetTxAvailable (void) const = 0;
 327 
 328  /**
 329   * \brief Send data (or dummy data) to the remote host
 330   *
 331   * This function matches closely in semantics to the send() function
 332   * call in the standard C library (libc):
 333   *   ssize_t send (int s, const void *msg, size_t len, int flags);
 334   * except that the send I/O is asynchronous.  This is the
 335   * primary Send method at this low-level API and must be implemented 
 336   * by subclasses.
 337   * 
 338   * In a typical blocking sockets model, this call would block upon
 339   * lack of space to hold the message to be sent.  In ns-3 at this
 340   * API, the call returns immediately in such a case, but the callback
 341   * registered with SetSendCallback() is invoked when the socket
 342   * has space (when it conceptually unblocks); this is an asynchronous
 343   * I/O model for send().
 344   * 
 345   * This variant of Send() uses class ns3::Packet to encapsulate
 346   * data, rather than providing a raw pointer and length field.
 347   * This allows an ns-3 application to attach tags if desired (such
 348   * as a flow ID) and may allow the simulator to avoid some data
 349   * copies.  Despite the appearance of sending Packets on a stream
 350   * socket, just think of it as a fancy byte buffer with streaming
 351   * semantics.
 352   *
 353   * If either the message buffer within the Packet is too long to pass 
 354   * atomically through the underlying protocol (for datagram sockets), 
 355   * or the message buffer cannot entirely fit in the transmit buffer
 356   * (for stream sockets), -1 is returned and SocketErrno is set 
 357   * to ERROR_MSGSIZE.  If the packet does not fit, the caller can
 358   * split the Packet (based on information obtained from 
 359   * GetTxAvailable) and reattempt to send the data.
 360   *
 361   * The flags argument is formed by or'ing one or more of the values:
 362   *        MSG_OOB        process out-of-band data 
 363   *        MSG_DONTROUTE  bypass routing, use direct interface 
 364   * These flags are _unsupported_ as of ns-3.1.
 365   *
 366   * \param p ns3::Packet to send
 367   * \param flags Socket control flags
 368   * \returns the number of bytes accepted for transmission if no error
 369   *          occurs, and -1 otherwise.
 370   *
 371   * \see SetSendCallback
 372   */
 373  virtual int Send (Ptr<Packet> p, uint32_t flags) = 0;
 374
 375  /**
 376   * \brief Send data to a specified peer.
 377   *
 378   * This method has similar semantics to Send () but subclasses may
 379   * want to provide checks on socket state, so the implementation is
 380   * pushed to subclasses.
 381   *
 382   * \param p packet to send
 383   * \param flags Socket control flags
 384   * \param toAddress IP Address of remote host
 385   * \returns -1 in case of error or the number of bytes copied in the 
 386   *          internal buffer and accepted for transmission.
 387   */
 388  virtual int SendTo (Ptr<Packet> p, uint32_t flags, 
 389                      const Address &toAddress) = 0;
 390
 391  /**
 392   * Return number of bytes which can be returned from one or 
 393   * multiple calls to Recv.
 394   * Must be possible to call this method from the Recv callback.
 395   *
 396   * \returns the number of bytes which can be returned from one or
 397   *          multiple Recv calls.
 398   */
 399  virtual uint32_t GetRxAvailable (void) const = 0;
 400
 401  /**
 402   * \brief Read data from the socket
 403   *
 404   * This function matches closely in semantics to the recv() function
 405   * call in the standard C library (libc):
 406   *   ssize_t recv (int s, void *buf, size_t len, int flags);
 407   * except that the receive I/O is asynchronous.  This is the
 408   * primary Recv method at this low-level API and must be implemented 
 409   * by subclasses.
 410   * 
 411   * This method is normally used only on a connected socket.
 412   * In a typical blocking sockets model, this call would block until
 413   * at least one byte is returned or the connection closes.
 414   * In ns-3 at this API, the call returns immediately in such a case
 415   * and returns 0 if nothing is available to be read.
 416   * However, an application can set a callback, ns3::SetRecvCallback,
 417   * to be notified of data being available to be read
 418   * (when it conceptually unblocks); this is an asynchronous
 419   * I/O model for recv().
 420   * 
 421   * This variant of Recv() uses class ns3::Packet to encapsulate
 422   * data, rather than providing a raw pointer and length field.
 423   * This allows an ns-3 application to attach tags if desired (such
 424   * as a flow ID) and may allow the simulator to avoid some data
 425   * copies.  Despite the appearance of receiving Packets on a stream
 426   * socket, just think of it as a fancy byte buffer with streaming
 427   * semantics.
 428   *
 429   * The semantics depend on the type of socket.  For a datagram socket,
 430   * each Recv() returns the data from at most one Send(), and order
 431   * is not necessarily preserved.  For a stream socket, the bytes
 432   * are delivered in order, and on-the-wire packet boundaries are
 433   * not preserved.
 434   * 
 435   * The flags argument is formed by or'ing one or more of the values:
 436   *        MSG_OOB             process out-of-band data
 437   *        MSG_PEEK            peek at incoming message
 438   * None of these flags are supported for now.
 439   *
 440   * Some variants of Recv() are supported as additional API,
 441   * including RecvFrom(), overloaded Recv() without arguments,
 442   * and variants that use raw character buffers.
 443   *
 444   * \param maxSize reader will accept packet up to maxSize
 445   * \param flags Socket control flags
 446   * \returns Ptr<Packet> of the next in-sequence packet.  Returns
 447   * 0 if the socket cannot return a next in-sequence packet conforming
 448   * to the maxSize and flags.
 449   *
 450   * \see SetRecvCallback
 451   */
 452  virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags) = 0;
 453
 454  /**
 455   * \brief Read a single packet from the socket and retrieve the sender 
 456   * address.
 457   *
 458   * Calls Recv(maxSize, flags) with maxSize
 459   * implicitly set to maximum sized integer, and flags set to zero.
 460   *
 461   * This method has similar semantics to Recv () but subclasses may
 462   * want to provide checks on socket state, so the implementation is
 463   * pushed to subclasses.
 464   *
 465   * \param maxSize reader will accept packet up to maxSize
 466   * \param flags Socket control flags
 467   * \param fromAddress output parameter that will return the
 468   * address of the sender of the received packet, if any.  Remains
 469   * untouched if no packet is received.
 470   * \returns Ptr<Packet> of the next in-sequence packet.  Returns
 471   * 0 if the socket cannot return a next in-sequence packet.
 472   */
 473  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
 474                                Address &fromAddress) = 0;
 475
 476  /////////////////////////////////////////////////////////////////////
 477  //   The remainder of these public methods are overloaded methods  //
 478  //   or variants of Send() and Recv(), and they are non-virtual    //
 479  /////////////////////////////////////////////////////////////////////
 480 
 481  /**
 482   * \brief Send data (or dummy data) to the remote host
 483   * 
 484   * Overloaded version of Send(..., flags) with flags set to zero.
 485   *
 486   * \param p ns3::Packet to send
 487   * \returns the number of bytes accepted for transmission if no error
 488   *          occurs, and -1 otherwise.
 489   */
 490  int Send (Ptr<Packet> p);
 491
 492  /**
 493   * \brief Send data (or dummy data) to the remote host
 494   * 
 495   * This method is provided so as to have an API which is closer in 
 496   * appearance to that of real network or BSD sockets.
 497   *
 498   * \param buf A pointer to a raw byte buffer of some data to send.  If 
 499   * this buffer is 0, we send dummy data whose size is specified by the 
 500   * second parameter
 501   * \param size the number of bytes to copy from the buffer
 502   * \param flags Socket control flags
 503   * \returns the number of bytes accepted for transmission if no error
 504   *          occurs, and -1 otherwise.
 505   */
 506  int Send (const uint8_t* buf, uint32_t size, uint32_t flags);
 507
 508
 509  /**
 510   * \brief Send data to a specified peer.
 511   *
 512   * This method is provided so as to have an API which is closer in 
 513   * appearance to that of real network or BSD sockets.
 514   *
 515   * \param buf A pointer to a raw byte buffer of some data to send.
 516   * If this is 0, we send dummy data whose size is specified by the 
 517   * third parameter
 518   * \param size the number of bytes to copy from the buffer
 519   * \param flags Socket control flags
 520   * \param address IP Address of remote host
 521   * \returns -1 in case of error or the number of bytes copied in the 
 522   *          internal buffer and accepted for transmission.
 523   *
 524   */
 525  int SendTo (const uint8_t* buf, uint32_t size, uint32_t flags, 
 526              const Address &address); 
 527
 528  /**
 529   * \brief Read a single packet from the socket
 530   *
 531   * Overloaded version of Recv(maxSize, flags) with maxSize
 532   * implicitly set to maximum sized integer, and flags set to zero.
 533   *
 534   * \returns Ptr<Packet> of the next in-sequence packet.  Returns
 535   * 0 if the socket cannot return a next in-sequence packet.
 536   */
 537  Ptr<Packet> Recv (void);
 538
 539  /**
 540   * \brief Recv data (or dummy data) from the remote host
 541   *
 542   * This method is provided so as to have an API which is closer in 
 543   * appearance to that of real network or BSD sockets.
 544   * 
 545   * If the underlying packet was carring null (fake) data, this buffer
 546   * will be zeroed up to the length specified by the return value.
 547   *
 548   * \param buf A pointer to a raw byte buffer to write the data to. 
 549   * \param size Number of bytes (at most) to copy to buf
 550   * \param flags any flags to pass to the socket
 551   * \returns number of bytes copied into buf
 552   */
 553  int Recv (uint8_t* buf, uint32_t size, uint32_t flags);
 554
 555  /**
 556   * \brief Read a single packet from the socket and retrieve the sender 
 557   * address.
 558   *
 559   * Calls RecvFrom (maxSize, flags, fromAddress) with maxSize
 560   * implicitly set to maximum sized integer, and flags set to zero.
 561   *
 562   * \param fromAddress output parameter that will return the
 563   * address of the sender of the received packet, if any.  Remains
 564   * untouched if no packet is received.
 565   * \returns Ptr<Packet> of the next in-sequence packet.  Returns
 566   * 0 if the socket cannot return a next in-sequence packet.
 567   */
 568  Ptr<Packet> RecvFrom (Address &fromAddress);
 569
 570  /**
 571   * \brief Read a single packet from the socket and retrieve the sender
 572   * address.
 573   *
 574   * This method is provided so as to have an API which is closer in 
 575   * appearance to that of real network or BSD sockets.
 576   * 
 577   * \param buf A pointer to a raw byte buffer to write the data to. 
 578   * If the underlying packet was carring null (fake) data, this buffer
 579   * will be zeroed up to the length specified by the return value.
 580   * \param size Number of bytes (at most) to copy to buf
 581   * \param flags any flags to pass to the socket
 582   * \param fromAddress output parameter that will return the
 583   * address of the sender of the received packet, if any.  Remains
 584   * untouched if no packet is received.
 585   * \returns number of bytes copied into buf
 586   */
 587  int RecvFrom (uint8_t* buf, uint32_t size, uint32_t flags,
 588                Address &fromAddress);
 589  /**
 590   * \brief Get socket address.
 591   * \param address the address name this socket is associated with.
 592   * \returns 0 if success, -1 otherwise
 593   */
 594  virtual int GetSockName (Address &address) const = 0; 
 595
 596  /**
 597   * \brief Get the peer address of a connected socket.
 598   * \param address the address this socket is connected to.
 599   * \returns 0 if success, -1 otherwise
 600   */
 601  virtual int GetPeerName (Address &address) const = 0;
 602
 603  /**
 604   * \brief Bind a socket to specific device.
 605   *
 606   * This method corresponds to using setsockopt() SO_BINDTODEVICE
 607   * of real network or BSD sockets.   If set on a socket, this option will
 608   * force packets to leave the bound device regardless of the device that
 609   * IP routing would naturally choose.  In the receive direction, only
 610   * packets received from the bound interface will be delivered.
 611   *
 612   * This option has no particular relationship to binding sockets to
 613   * an address via Socket::Bind ().  It is possible to bind sockets to a 
 614   * specific IP address on the bound interface by calling both 
 615   * Socket::Bind (address) and Socket::BindToNetDevice (device), but it
 616   * is also possible to bind to mismatching device and address, even if
 617   * the socket can not receive any packets as a result.
 618   *
 619   * \param netdevice Pointer to NetDevice of desired interface
 620   * \returns nothing
 621   */
 622  virtual void BindToNetDevice (Ptr<NetDevice> netdevice);
 623
 624  /**
 625   * \brief Returns socket's bound NetDevice, if any.
 626   *
 627   * This method corresponds to using getsockopt() SO_BINDTODEVICE
 628   * of real network or BSD sockets.
 629   * 
 630   * 
 631   * \returns Pointer to interface.
 632   */
 633  Ptr<NetDevice> GetBoundNetDevice (); 
 634
 635
 636  /**
 637   * \brief Configure whether broadcast datagram transmissions are allowed
 638   *
 639   * This method corresponds to using setsockopt() SO_BROADCAST of
 640   * real network or BSD sockets.  If set on a socket, this option
 641   * will enable or disable packets to be transmitted to broadcast
 642   * destination addresses.
 643   *
 644   * \param allowBroadcast Whether broadcast is allowed
 645   * \return true if operation succeeds
 646   */
 647  virtual bool SetAllowBroadcast (bool allowBroadcast) = 0;
 648
 649  /**
 650   * \brief Query whether broadcast datagram transmissions are allowed
 651   *
 652   * This method corresponds to using getsockopt() SO_BROADCAST of
 653   * real network or BSD sockets.
 654   *
 655   * \returns true if broadcast is allowed, false otherwise
 656   */
 657  virtual bool GetAllowBroadcast () const = 0;
 658
 659  /**
 660   * \brief Enable/Disable receive packet information to socket.
 661   *
 662   * For IP_PKTINFO/IP6_PKTINFO. This method is only usable for 
 663   * Raw socket and Datagram Socket. Not supported for Stream socket.
 664   *
 665   * Method doesn't make distinction between IPv4 and IPv6. If it is enabled,
 666   * it is enabled for all types of sockets that supports packet information
 667   *
 668   * \param flag Enable/Disable receive information
 669   * \returns nothing
 670   */
 671  void SetRecvPktInfo (bool flag);
 672
 673  /**
 674   * \brief Get status indicating whether enable/disable packet information to socket
 675   *
 676   * \returns True if packet information should be sent to socket
 677   */
 678  bool IsRecvPktInfo () const;
 679
 680  /**
 681   * \brief Manually set the socket priority
 682   *
 683   * This method corresponds to using setsockopt () SO_PRIORITY of
 684   * real network or BSD sockets.
 685   *
 686   * \param priority The socket priority (in the range 0..6)
 687   */
 688  void SetPriority (uint8_t priority);
 689
 690  /**
 691   * \brief Query the priority value of this socket
 692   *
 693   * This method corresponds to using getsockopt () SO_PRIORITY of real network
 694   * or BSD sockets.
 695   *
 696   * \return The priority value
 697   */
 698  uint8_t GetPriority (void) const;
 699
 700  /**
 701   * \brief Return the priority corresponding to a given TOS value
 702   *
 703   * This function is implemented after the Linux rt_tos2priority
 704   * function. The usage of the TOS byte has been originally defined by
 705   * RFC 1349 (http://www.ietf.org/rfc/rfc1349.txt):
 706   *
 707   *               0     1     2     3     4     5     6     7
 708   *           +-----+-----+-----+-----+-----+-----+-----+-----+
 709   *           |   PRECEDENCE    |          TOS          | MBZ |
 710   *           +-----+-----+-----+-----+-----+-----+-----+-----+
 711   *
 712   * where MBZ stands for 'must be zero'.
 713   *
 714   * The Linux rt_tos2priority function ignores the precedence bits and
 715   * maps each of the 16 values coded in bits 3-6 as follows:
 716   *
 717   * Bits 3-6 | Means                   | Linux Priority
 718   * ---------|-------------------------|----------------
 719   *     0    |  Normal Service         | Best Effort (0)
 720   *     1    |  Minimize Monetary Cost | Best Effort (0)
 721   *     2    |  Maximize Reliability   | Best Effort (0)
 722   *     3    |  mmc+mr                 | Best Effort (0)
 723   *     4    |  Maximize Throughput    | Bulk (2)
 724   *     5    |  mmc+mt                 | Bulk (2)
 725   *     6    |  mr+mt                  | Bulk (2)
 726   *     7    |  mmc+mr+mt              | Bulk (2)
 727   *     8    |  Minimize Delay         | Interactive (6)
 728   *     9    |  mmc+md                 | Interactive (6)
 729   *    10    |  mr+md                  | Interactive (6)
 730   *    11    |  mmc+mr+md              | Interactive (6)
 731   *    12    |  mt+md                  | Int. Bulk (4)
 732   *    13    |  mmc+mt+md              | Int. Bulk (4)
 733   *    14    |  mr+mt+md               | Int. Bulk (4)
 734   *    15    |  mmc+mr+mt+md           | Int. Bulk (4)
 735   *
 736   * RFC 2474 (http://www.ietf.org/rfc/rfc2474.txt) redefines the TOS byte:
 737   *
 738   *               0     1     2     3     4     5     6     7
 739   *           +-----+-----+-----+-----+-----+-----+-----+-----+
 740   *           |              DSCP                 |     CU    |
 741   *           +-----+-----+-----+-----+-----+-----+-----+-----+
 742   *
 743   * where DSCP is the Differentiated Services Code Point and CU stands for
 744   * 'currently unused' (actually, RFC 3168 proposes to use these two bits for
 745   * ECN purposes). The table above allows to determine how the Linux
 746   * rt_tos2priority function maps each DSCP value to a priority value. Such a
 747   * mapping is shown below.
 748   *
 749   * DSCP | Hex  | TOS (binary) | bits 3-6 | Linux Priority
 750   * -----|------|--------------|----------|----------------
 751   * EF   | 0x2E |   101110xx   |  12-13   |  Int. Bulk (4)
 752   * AF11 | 0x0A |   001010xx   |   4-5    |  Bulk (2)
 753   * AF21 | 0x12 |   010010xx   |   4-5    |  Bulk (2)
 754   * AF31 | 0x1A |   011010xx   |   4-5    |  Bulk (2)
 755   * AF41 | 0x22 |   100010xx   |   4-5    |  Bulk (2)
 756   * AF12 | 0x0C |   001100xx   |   8-9    |  Interactive (6)
 757   * AF22 | 0x14 |   010100xx   |   8-9    |  Interactive (6)
 758   * AF32 | 0x1C |   011100xx   |   8-9    |  Interactive (6)
 759   * AF42 | 0x24 |   100100xx   |   8-9    |  Interactive (6)
 760   * AF13 | 0x0E |   001110xx   |  12-13   |  Int. Bulk (4)
 761   * AF23 | 0x16 |   010110xx   |  12-13   |  Int. Bulk (4)
 762   * AF33 | 0x1E |   011110xx   |  12-13   |  Int. Bulk (4)
 763   * AF43 | 0x26 |   100110xx   |  12-13   |  Int. Bulk (4)
 764   * CS0  | 0x00 |   000000xx   |   0-1    |  Best Effort (0)
 765   * CS1  | 0x08 |   001000xx   |   0-1    |  Best Effort (0)
 766   * CS2  | 0x10 |   010000xx   |   0-1    |  Best Effort (0)
 767   * CS3  | 0x18 |   011000xx   |   0-1    |  Best Effort (0)
 768   * CS4  | 0x20 |   100000xx   |   0-1    |  Best Effort (0)
 769   * CS5  | 0x28 |   101000xx   |   0-1    |  Best Effort (0)
 770   * CS6  | 0x30 |   110000xx   |   0-1    |  Best Effort (0)
 771   * CS7  | 0x38 |   111000xx   |   0-1    |  Best Effort (0)
 772   *
 773   * \param ipTos the TOS value (in the range 0..255)
 774   * \return The priority value corresponding to the given TOS value
 775   */
 776  static uint8_t IpTos2Priority (uint8_t ipTos);
 777
 778  /**
 779   * \brief Manually set IP Type of Service field
 780   * 
 781   * This method corresponds to using setsockopt () IP_TOS of
 782   * real network or BSD sockets. This option is for IPv4 only.
 783   * Setting the IP TOS also changes the socket priority as
 784   * stated in the man page.
 785   *
 786   * \param ipTos The desired TOS value for IP headers
 787   */
 788  void SetIpTos (uint8_t ipTos);
 789
 790  /**
 791   * \brief Query the value of IP Type of Service of this socket
 792   *
 793   * This method corresponds to using getsockopt () IP_TOS of real network
 794   * or BSD sockets.
 795   *
 796   * \return The raw IP TOS value
 797   */
 798  uint8_t GetIpTos (void) const;
 799
 800  /**
 801   * \brief Tells a socket to pass information about IP Type of Service up the stack
 802   *
 803   * This method corresponds to using setsockopt () IP_RECVTOS of real
 804   * network or BSD sockets. In our implementation, the socket simply 
 805   * adds a SocketIpTosTag tag to the packet before passing the
 806   * packet up the stack.
 807   *
 808   * \param ipv4RecvTos Whether the socket should add SocketIpv4TosTag tag
 809   * to the packet
 810   */
 811  void SetIpRecvTos (bool ipv4RecvTos);
 812
 813  /**
 814   * \brief Ask if the socket is currently passing information about IP Type of Service up the stack
 815   *
 816   * This method corresponds to using getsockopt () IP_RECVTOS of real
 817   * network or BSD sockets.
 818   *
 819   * \return Whether the IP_RECVTOS is set
 820   */
 821  bool IsIpRecvTos (void) const;
 822
 823  /**
 824   * \brief Manually set IPv6 Traffic Class field
 825   * 
 826   * This method corresponds to using setsockopt () IPV6_TCLASS of
 827   * real network or BSD sockets. This option is for IPv6 only.
 828   * Setting the IPV6_TCLASSS to -1 clears the option and let the socket
 829   * uses the default value.
 830   *
 831   * \param ipTclass The desired TCLASS value for IPv6 headers
 832   */
 833  void SetIpv6Tclass (int ipTclass);
 834
 835  /**
 836   * \brief Query the value of IPv6 Traffic Class field of this socket
 837   *
 838   * This method corresponds to using getsockopt () IPV6_TCLASS of real network
 839   * or BSD sockets.
 840   *
 841   * \return The raw IPV6_TCLASS value
 842   */
 843  uint8_t GetIpv6Tclass (void) const;
 844
 845  /**
 846   * \brief Tells a socket to pass information about IPv6 Traffic Class up the stack
 847   *
 848   * This method corresponds to using setsockopt () IPV6_RECVTCLASS of real
 849   * network or BSD sockets. In our implementation, the socket simply 
 850   * adds a SocketIpv6TclasssTag tag to the packet before passing the
 851   * packet up the stack.
 852   *
 853   * \param ipv6RecvTclass Whether the socket should add SocketIpv6TclassTag tag
 854   * to the packet
 855   */
 856  void SetIpv6RecvTclass (bool ipv6RecvTclass);
 857
 858  /**
 859   * \brief Ask if the socket is currently passing information about IPv6 Traffic Class up the stack
 860   *
 861   * This method corresponds to using getsockopt () IPV6_RECVTCLASS of real
 862   * network or BSD sockets.
 863   *
 864   * \return Whether the IPV6_RECVTCLASS is set
 865   */
 866  bool IsIpv6RecvTclass (void) const;
 867
 868  /**
 869   * \brief Manually set IP Time to Live field
 870   * 
 871   * This method corresponds to using setsockopt () IP_TTL of
 872   * real network or BSD sockets.
 873   *
 874   * \param ipTtl The desired TTL value for IP headers
 875   */
 876  virtual void SetIpTtl (uint8_t ipTtl);
 877
 878  /**
 879   * \brief Query the value of IP Time to Live field of this socket
 880   *
 881   * This method corresponds to using getsockopt () IP_TTL of real network
 882   * or BSD sockets.
 883   *
 884   * \return The raw IP TTL value
 885   */
 886  virtual uint8_t GetIpTtl (void) const;
 887
 888  /**
 889   * \brief Tells a socket to pass information about IP_TTL up the stack
 890   *
 891   * This method corresponds to using setsockopt () IP_RECVTTL of real
 892   * network or BSD sockets. In our implementation, the socket simply 
 893   * adds a SocketIpTtlTag tag to the packet before passing the
 894   * packet up the stack.
 895   *
 896   * \param ipv4RecvTtl Whether the socket should add SocketIpv4TtlTag tag
 897   * to the packet
 898   */
 899  void SetIpRecvTtl (bool ipv4RecvTtl);
 900
 901  /**
 902   * \brief Ask if the socket is currently passing information about IP_TTL up the stack
 903   *
 904   * This method corresponds to using getsockopt () IP_RECVTTL of real
 905   * network or BSD sockets.
 906   *
 907   * \return Whether the IP_RECVTTL is set
 908   */
 909  bool IsIpRecvTtl (void) const;
 910
 911  /**
 912   * \brief Manually set IPv6 Hop Limit
 913   * 
 914   * This method corresponds to using setsockopt () IPV6_HOPLIMIT of
 915   * real network or BSD sockets.
 916   *
 917   * \param ipHopLimit The desired Hop Limit value for IPv6 headers
 918   */
 919  virtual void SetIpv6HopLimit (uint8_t ipHopLimit);
 920
 921  /**
 922   * \brief Query the value of IP Hop Limit field of this socket
 923   *
 924   * This method corresponds to using getsockopt () IPV6_HOPLIMIT of real network
 925   * or BSD sockets.
 926   *
 927   * \return The raw IPv6 Hop Limit value
 928   */
 929  virtual uint8_t GetIpv6HopLimit (void) const;
 930
 931  /**
 932   * \brief Tells a socket to pass information about IPv6 Hop Limit up the stack
 933   *
 934   * This method corresponds to using setsockopt () IPV6_RECVHOPLIMIT of real
 935   * network or BSD sockets. In our implementation, the socket simply 
 936   * adds a SocketIpv6HopLimitTag tag to the packet before passing the
 937   * packet up the stack.
 938   *
 939   * \param ipv6RecvHopLimit Whether the socket should add SocketIpv6HopLimitTag tag
 940   * to the packet
 941   */
 942  void SetIpv6RecvHopLimit (bool ipv6RecvHopLimit);
 943
 944  /**
 945   * \brief Ask if the socket is currently passing information about IPv6 Hop Limit up the stack
 946   *
 947   * This method corresponds to using getsockopt () IPV6_RECVHOPLIMIT of real
 948   * network or BSD sockets.
 949   *
 950   * \return Whether the IPV6_RECVHOPLIMIT is set
 951   */
 952  bool IsIpv6RecvHopLimit (void) const;
 953 
 954  /**
 955   * \brief Joins a IPv6 multicast group.
 956   *
 957   * Based on the filter mode and source addresses this can be interpreted as a
 958   * join, leave, or modification to source filtering on a multicast group.
 959   *
 960   * Mind that a socket can join only one multicast group. Any attempt to join another group will remove the old one.
 961   *
 962   *
 963   * \param address Requested multicast address.
 964   * \param filterMode Socket filtering mode (INCLUDE | EXCLUDE).
 965   * \param sourceAddresses All the source addresses on which socket is interested or not interested.
 966   */
 967  virtual void Ipv6JoinGroup (Ipv6Address address, Ipv6MulticastFilterMode filterMode, std::vector<Ipv6Address> sourceAddresses);
 968
 969  /**
 970   * \brief Joins a IPv6 multicast group without filters.
 971   *
 972   * A socket can join only one multicast group. Any attempt to join another group will remove the old one.
 973   *
 974   * \param address Group address on which socket wants to join.
 975   */
 976  virtual void Ipv6JoinGroup (Ipv6Address address);
 977
 978  /**
 979   * \brief Leaves IPv6 multicast group this socket is joined to.
 980   */
 981  virtual void Ipv6LeaveGroup (void);
 982
 983protected:
 984  /**
 985   * \brief Notify through the callback (if set) that the connection has been
 986   *        established.
 987   */
 988  void NotifyConnectionSucceeded (void);
 989
 990  /**
 991   * \brief Notify through the callback (if set) that the connection has not been
 992   *        established due to an error.
 993   */
 994  void NotifyConnectionFailed (void);
 995
 996  /**
 997   * \brief Notify through the callback (if set) that the connection has been
 998   *        closed.
 999   */
1000  void NotifyNormalClose (void);
1001
1002  /**
1003   * \brief Notify through the callback (if set) that the connection has been
1004   *        closed due to an error.
1005   */
1006  void NotifyErrorClose (void);
1007
1008  /**
1009   * \brief Notify through the callback (if set) that an incoming connection
1010   *        is being requested by a remote host.
1011   *
1012   * This function returns true by default (i.e., accept all the incoming connections).
1013   * The callback (if set) might restrict this behaviour by returning zero for a
1014   * connection that should be refused.
1015   *
1016   * \param from the address the connection is incoming from
1017   * \returns true if the connection must be accepted, false otherwise.
1018   */
1019  bool NotifyConnectionRequest (const Address &from);
1020
1021  /**
1022   * \brief Notify through the callback (if set) that a new connection has been
1023   *        created.
1024   * \param socket The socket receiving the new connection.
1025   * \param from The address of the node initiating the connection.
1026   */
1027  void NotifyNewConnectionCreated (Ptr<Socket> socket, const Address &from);
1028
1029  /**
1030   * \brief Notify through the callback (if set) that some data have been sent.
1031   *
1032   * \param size number of sent bytes.
1033   */
1034  void NotifyDataSent (uint32_t size);
1035
1036  /**
1037   * \brief Notify through the callback (if set) that some data have been sent.
1038   *
1039   * \param spaceAvailable the number of bytes available in the transmission buffer.
1040   */
1041  void NotifySend (uint32_t spaceAvailable);
1042
1043  /**
1044   * \brief Notify through the callback (if set) that some data have been received.
1045   */
1046  void NotifyDataRecv (void);
1047
1048  // inherited function, no doc necessary
1049  virtual void DoDispose (void);
1050
1051  /**
1052   * \brief Checks if the socket has a specific IPv6 Tclass set
1053   *
1054   * \returns true if the socket has a IPv6 Tclass set, false otherwise.
1055   */
1056  bool IsManualIpv6Tclass (void) const;
1057
1058  /**
1059   * \brief Checks if the socket has a specific IPv4 TTL set
1060   *
1061   * \returns true if the socket has a IPv4 TTL set, false otherwise.
1062   */
1063  bool IsManualIpTtl (void) const;
1064
1065  /**
1066   * \brief Checks if the socket has a specific IPv6 Hop Limit set
1067   *
1068   * \returns true if the socket has a IPv6 Hop Limit set, false otherwise.
1069   */
1070  bool IsManualIpv6HopLimit (void) const;
1071
1072  Ptr<NetDevice> m_boundnetdevice; //!< the device this socket is bound to (might be null).
1073  bool m_recvPktInfo; //!< if the socket should add packet info tags to the packet forwarded to L4.
1074  Ipv6Address m_ipv6MulticastGroupAddress; //!< IPv6 multicast group address.
1075
1076private:
1077  Callback<void, Ptr<Socket> >                   m_connectionSucceeded;  //!< connection succeeded callback
1078  Callback<void, Ptr<Socket> >                   m_connectionFailed;     //!< connection failed callback
1079  Callback<void, Ptr<Socket> >                   m_normalClose;          //!< connection closed callback
1080  Callback<void, Ptr<Socket> >                   m_errorClose;           //!< connection closed due to errors callback
1081  Callback<bool, Ptr<Socket>, const Address &>   m_connectionRequest;    //!< connection request callback
1082  Callback<void, Ptr<Socket>, const Address&>    m_newConnectionCreated; //!< connection created callback
1083  Callback<void, Ptr<Socket>, uint32_t>          m_dataSent;             //!< data sent callback
1084  Callback<void, Ptr<Socket>, uint32_t >         m_sendCb;               //!< packet sent callback
1085  Callback<void, Ptr<Socket> >                   m_receivedData;         //!< data received callback
1086
1087  uint8_t m_priority; //!< the socket priority
1088
1089  //IPv4 options
1090  bool m_manualIpTtl; //!< socket has IPv4 TTL set
1091  bool m_ipRecvTos;   //!< socket forwards IPv4 TOS tag to L4
1092  bool m_ipRecvTtl;   //!< socket forwards IPv4 TTL tag to L4
1093
1094  uint8_t m_ipTos; //!< the socket IPv4 TOS
1095  uint8_t m_ipTtl; //!< the socket IPv4 TTL
1096
1097  //IPv6 options
1098  bool m_manualIpv6Tclass;    //!< socket has IPv6 Tclass set
1099  bool m_manualIpv6HopLimit;  //!< socket has IPv6 Hop Limit set
1100  bool m_ipv6RecvTclass;      //!< socket forwards IPv6 Tclass tag to L4
1101  bool m_ipv6RecvHopLimit;    //!< socket forwards IPv6 Hop Limit tag to L4
1102
1103  uint8_t m_ipv6Tclass;     //!< the socket IPv6 Tclass
1104  uint8_t m_ipv6HopLimit;   //!< the socket IPv6 Hop Limit
1105};
1106
1107/**
1108 * \brief This class implements a tag that carries the socket-specific
1109 * TTL of a packet to the IP layer
1110 */
1111class SocketIpTtlTag : public Tag
1112{
1113public:
1114  SocketIpTtlTag ();
1115
1116  /**
1117   * \brief Set the tag's TTL
1118   *
1119   * \param ttl the TTL
1120   */
1121  void SetTtl (uint8_t ttl);
1122
1123  /**
1124   * \brief Get the tag's TTL
1125   *
1126   * \returns the TTL
1127   */
1128  uint8_t GetTtl (void) const;
1129
1130  /**
1131   * \brief Get the type ID.
1132   * \return the object TypeId
1133   */
1134  static TypeId GetTypeId (void);
1135
1136  // inherited function, no need to doc.
1137  virtual TypeId GetInstanceTypeId (void) const;
1138
1139  // inherited function, no need to doc.
1140  virtual uint32_t GetSerializedSize (void) const;
1141
1142  // inherited function, no need to doc.
1143  virtual void Serialize (TagBuffer i) const;
1144
1145  // inherited function, no need to doc.
1146  virtual void Deserialize (TagBuffer i);
1147
1148  // inherited function, no need to doc.
1149  virtual void Print (std::ostream &os) const;
1150
1151private:
1152  uint8_t m_ttl; //!< the ttl carried by the tag
1153};
1154
1155/**
1156 * \brief This class implements a tag that carries the socket-specific
1157 * HOPLIMIT of a packet to the IPv6 layer
1158 */
1159class SocketIpv6HopLimitTag : public Tag
1160{
1161public:
1162  SocketIpv6HopLimitTag ();
1163
1164  /**
1165   * \brief Set the tag's Hop Limit
1166   *
1167   * \param hopLimit the Hop Limit
1168   */
1169  void SetHopLimit (uint8_t hopLimit);
1170
1171  /**
1172   * \brief Get the tag's Hop Limit
1173   *
1174   * \returns the Hop Limit
1175   */
1176  uint8_t GetHopLimit (void) const;
1177
1178  /**
1179   * \brief Get the type ID.
1180   * \return the object TypeId
1181   */
1182  static TypeId GetTypeId (void);
1183
1184  // inherited function, no need to doc.
1185  virtual TypeId GetInstanceTypeId (void) const;
1186
1187  // inherited function, no need to doc.
1188  virtual uint32_t GetSerializedSize (void) const;
1189
1190  // inherited function, no need to doc.
1191  virtual void Serialize (TagBuffer i) const;
1192
1193  // inherited function, no need to doc.
1194  virtual void Deserialize (TagBuffer i);
1195
1196  // inherited function, no need to doc.
1197  virtual void Print (std::ostream &os) const;
1198
1199private:
1200  uint8_t m_hopLimit; //!< the Hop Limit carried by the tag
1201};
1202
1203/**
1204 * \brief indicates whether packets should be sent out with
1205 * the DF (Don't Fragment) flag set.
1206 */
1207class SocketSetDontFragmentTag : public Tag
1208{
1209public:
1210  SocketSetDontFragmentTag ();
1211
1212  /**
1213   * \brief Enables the DF (Don't Fragment) flag
1214   */
1215  void Enable (void);
1216
1217  /**
1218   * \brief Disables the DF (Don't Fragment) flag
1219   */
1220  void Disable (void);
1221
1222  /**
1223   * \brief Checks if the DF (Don't Fragment) flag is set
1224   *
1225   * \returns true if DF is set.
1226   */
1227  bool IsEnabled (void) const;
1228
1229  /**
1230   * \brief Get the type ID.
1231   * \return the object TypeId
1232   */
1233  static TypeId GetTypeId (void);
1234
1235  // inherited function, no need to doc.
1236  virtual TypeId GetInstanceTypeId (void) const;
1237
1238  // inherited function, no need to doc.
1239  virtual uint32_t GetSerializedSize (void) const;
1240
1241  // inherited function, no need to doc.
1242  virtual void Serialize (TagBuffer i) const;
1243
1244  // inherited function, no need to doc.
1245  virtual void Deserialize (TagBuffer i);
1246
1247  // inherited function, no need to doc.
1248  virtual void Print (std::ostream &os) const;
1249private:
1250  bool m_dontFragment; //!< DF bit value for outgoing packets.
1251};
1252
1253/**
1254 * \brief indicates whether the socket has IP_TOS set.
1255 * This tag is for IPv4 socket.
1256 */
1257class SocketIpTosTag : public Tag
1258{
1259public:
1260  SocketIpTosTag ();
1261
1262  /**
1263   * \brief Set the tag's TOS
1264   *
1265   * \param tos the TOS
1266   */
1267  void SetTos (uint8_t tos);
1268
1269  /**
1270   * \brief Get the tag's TOS
1271   *
1272   * \returns the TOS
1273   */
1274  uint8_t GetTos (void) const;
1275  
1276  /**
1277   * \brief Get the type ID.
1278   * \return the object TypeId
1279   */
1280  static TypeId GetTypeId (void);
1281
1282  // inherited function, no need to doc.
1283  virtual TypeId GetInstanceTypeId (void) const;
1284
1285  // inherited function, no need to doc.
1286  virtual uint32_t GetSerializedSize (void) const;
1287
1288  // inherited function, no need to doc.
1289  virtual void Serialize (TagBuffer i) const;
1290
1291  // inherited function, no need to doc.
1292  virtual void Deserialize (TagBuffer i);
1293
1294  // inherited function, no need to doc.
1295  virtual void Print (std::ostream &os) const;
1296private:
1297  uint8_t m_ipTos;  //!< the TOS carried by the tag
1298};
1299
1300/**
1301 * \brief indicates whether the socket has a priority set.
1302 */
1303class SocketPriorityTag : public Tag
1304{
1305public:
1306  SocketPriorityTag ();
1307
1308  /**
1309   * \brief Set the tag's priority
1310   *
1311   * \param priority the priority
1312   */
1313  void SetPriority (uint8_t priority);
1314
1315  /**
1316   * \brief Get the tag's priority
1317   *
1318   * \returns the priority
1319   */
1320  uint8_t GetPriority (void) const;
1321
1322  /**
1323   * \brief Get the type ID.
1324   * \return the object TypeId
1325   */
1326  static TypeId GetTypeId (void);
1327
1328  // inherited function, no need to doc.
1329  virtual TypeId GetInstanceTypeId (void) const;
1330
1331  // inherited function, no need to doc.
1332  virtual uint32_t GetSerializedSize (void) const;
1333
1334  // inherited function, no need to doc.
1335  virtual void Serialize (TagBuffer i) const;
1336
1337  // inherited function, no need to doc.
1338  virtual void Deserialize (TagBuffer i);
1339
1340  // inherited function, no need to doc.
1341  virtual void Print (std::ostream &os) const;
1342private:
1343  uint8_t m_priority;  //!< the priority carried by the tag
1344};
1345
1346/**
1347 * \brief indicates whether the socket has IPV6_TCLASS set.
1348 * This tag is for IPv6 socket.
1349 */
1350class SocketIpv6TclassTag : public Tag
1351{
1352public:
1353  SocketIpv6TclassTag ();
1354
1355  /**
1356   * \brief Set the tag's Tclass
1357   *
1358   * \param tclass the Tclass
1359   */
1360  void SetTclass (uint8_t tclass);
1361
1362  /**
1363   * \brief Get the tag's Tclass
1364   *
1365   * \returns the Tclass
1366   */
1367  uint8_t GetTclass (void) const;
1368  
1369  /**
1370   * \brief Get the type ID.
1371   * \return the object TypeId
1372   */
1373  static TypeId GetTypeId (void);
1374
1375  // inherited function, no need to doc.
1376  virtual TypeId GetInstanceTypeId (void) const;
1377
1378  // inherited function, no need to doc.
1379  virtual uint32_t GetSerializedSize (void) const;
1380
1381  // inherited function, no need to doc.
1382  virtual void Serialize (TagBuffer i) const;
1383
1384  // inherited function, no need to doc.
1385  virtual void Deserialize (TagBuffer i);
1386
1387  // inherited function, no need to doc.
1388  virtual void Print (std::ostream &os) const;
1389private:
1390  uint8_t m_ipv6Tclass; //!< the Tclass carried by the tag
1391};
1392
1393} // namespace ns3
1394
1395#endif /* NS3_SOCKET_H */