src/internet-stack/nsc-tcp-l4-protocol.h
author Florian Westphal <fw@strlen.de>
Wed Jul 15 18:46:14 2009 +0200 (2009-07-15)
changeset 4685 ae536d9e0d6d
parent 4472 e20a31541404
permissions -rw-r--r--
nsc: move nsc glue code from nsc-tcp-l4-protocol to node/nsc-glue.cc.

known problems:
- sim_interface.h is duplicated
- nsc-glue.cc adds hooks in node.cc, "hijacks" incoming packets
- nsc-glue exports NSCs INetStack (instead of wrapping it completely)
- nsc-tcp-l4-protocol and nsc-tcp-socket-impl make calls into nsc-glue
- nsc-tcp-socket-impl should really be "nsc-socket-core" (or something
like that)

needs fixing on nsc side:
- no support for multiple interfaces yet (also not yet supported
on nsc side)
- nsc initialisation still tied to IP (Adding an Interface and assigning the
IP address is a single step; it should be separate)

maybe there is more.

There is a NSC_NEXT define in nsc-glue.h, its main purpose is to flag
the places where the NSC API needs to be adapted to support multiple
interfaces in nsc.
fw@3578
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
fw@3578
     2
/*
fw@3578
     3
 * This program is free software; you can redistribute it and/or modify
fw@3578
     4
 * it under the terms of the GNU General Public License version 2 as
fw@3578
     5
 * published by the Free Software Foundation;
fw@3578
     6
 *
fw@3578
     7
 * This program is distributed in the hope that it will be useful,
fw@3578
     8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
fw@3578
     9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
fw@3578
    10
 * GNU General Public License for more details.
fw@3578
    11
 *
fw@3578
    12
 * You should have received a copy of the GNU General Public License
fw@3578
    13
 * along with this program; if not, write to the Free Software
fw@3578
    14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
fw@3578
    15
 */
fw@3578
    16
fw@3578
    17
#ifndef NSC_TCP_L4_PROTOCOL_H
fw@3578
    18
#define NSC_TCP_L4_PROTOCOL_H
fw@3578
    19
fw@3578
    20
#include <stdint.h>
fw@3578
    21
fw@3578
    22
#include "ns3/packet.h"
fw@3578
    23
#include "ns3/ipv4-address.h"
fw@3578
    24
#include "ns3/ptr.h"
fw@3578
    25
#include "ns3/object-factory.h"
fw@3578
    26
#include "ipv4-end-point-demux.h"
fw@3578
    27
#include "ipv4-l4-protocol.h"
fw@3578
    28
#include "ipv4-interface.h"
fw@3578
    29
fw@3578
    30
#include "tcp-header.h"
fw@3578
    31
fw@4685
    32
#include "nsc-tcp-socket-impl.h"
mathieu@3635
    33
#include "sim_interface.h"
fw@3578
    34
namespace ns3 {
fw@3578
    35
fw@3578
    36
class Node;
fw@3578
    37
class Socket;
fw@3578
    38
class TcpHeader;
fw@3578
    39
/**
tomh@3691
    40
 * \ingroup nsctcp
fw@4685
    41
 *
tomh@3691
    42
 * \brief Nsc wrapper glue, to interface with the Ipv4 protocol underneath.
fw@3578
    43
 */
fw@4685
    44
class NscTcpL4Protocol : public Ipv4L4Protocol {
fw@3578
    45
public:
fw@3578
    46
  static const uint8_t PROT_NUMBER;
fw@3578
    47
  static TypeId GetTypeId (void);
fw@3578
    48
  /**
fw@3578
    49
   * \brief Constructor
fw@3578
    50
   */
fw@3578
    51
  NscTcpL4Protocol ();
fw@3578
    52
fw@3578
    53
  void SetNode (Ptr<Node> node);
fw@4685
    54
fw@4685
    55
  // legacy, moved to node/node.cc
tomh@4472
    56
  void SetNscLibrary (const std::string &lib);
tomh@4472
    57
  std::string GetNscLibrary (void) const;
fw@4685
    58
fw@3578
    59
  virtual int GetProtocolNumber (void) const;
fw@3578
    60
  virtual int GetVersion (void) const;
fw@3578
    61
fw@3578
    62
  /**
fw@3578
    63
   * \return A smart Socket pointer to a NscTcpSocketImpl, allocated by this instance
fw@3578
    64
   * of the TCP protocol
fw@3578
    65
   */
fw@3578
    66
  Ptr<Socket> CreateSocket (void);
fw@3578
    67
fw@3578
    68
  Ipv4EndPoint *Allocate (void);
fw@3578
    69
  Ipv4EndPoint *Allocate (Ipv4Address address);
fw@3578
    70
  Ipv4EndPoint *Allocate (uint16_t port);
fw@3578
    71
  Ipv4EndPoint *Allocate (Ipv4Address address, uint16_t port);
fw@3578
    72
  Ipv4EndPoint *Allocate (Ipv4Address localAddress, uint16_t localPort,
fw@3578
    73
                          Ipv4Address peerAddress, uint16_t peerPort);
fw@3578
    74
fw@3578
    75
  void DeAllocate (Ipv4EndPoint *endPoint);
fw@3578
    76
fw@3578
    77
  /**
fw@3578
    78
   * \brief Recieve a packet up the protocol stack
fw@3578
    79
   * \param p The Packet to dump the contents into
fw@3578
    80
   * \param source The source's Ipv4Address
fw@3578
    81
   * \param destination The destinations Ipv4Address
fw@3578
    82
   * \param incomingInterface The Ipv4Interface it was received on
fw@3578
    83
   */
fw@4685
    84
fw@4685
    85
  // Stub function, not used in nsc
craigdo@3820
    86
  virtual Ipv4L4Protocol::RxStatus Receive (Ptr<Packet> p,
fw@4685
    87
                       Ipv4Address const &source,
fw@4685
    88
                       Ipv4Address const &destination,
fw@4685
    89
                       Ptr<Ipv4Interface> incomingInterface);
fw@3578
    90
fw@3578
    91
protected:
fw@3578
    92
  virtual void DoDispose (void);
tomh@4472
    93
  virtual void NotifyNewAggregate ();
fw@3578
    94
private:
fw@3578
    95
  Ptr<Node> m_node;
fw@3578
    96
  Ipv4EndPointDemux *m_endPoints;
fw@3578
    97
  ObjectFactory m_rttFactory;
fw@3578
    98
private:
fw@3578
    99
  static ObjectFactory GetDefaultRttEstimatorFactory (void);
fw@3578
   100
  friend class NscTcpSocketImpl;
fw@3578
   101
  INetStack* m_nscStack;
fw@4685
   102
  void Wakeup (void);
tomh@4472
   103
  std::string m_nscLibrary;
craigdo@4283
   104
  std::vector<Ptr<NscTcpSocketImpl> > m_sockets;
fw@3578
   105
};
fw@3578
   106
fw@3578
   107
}; // namespace ns3
fw@3578
   108
fw@3578
   109
#endif /* NSC_TCP_L4_PROTOCOL_H */