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