src/node/node.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu, 03 May 2007 12:46:50 +0200
changeset 514 7c9a037a32b7
parent 513 b7c7ea629de9
child 516 3d330150ab6d
permissions -rw-r--r--
make Ipv4L4Demux an NsUnknown object.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
233
6b60d7b27ae4 change emacs style commands
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 232
diff changeset
     1
// -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*-
232
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
//
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
// Copyright (c) 2006 Georgia Tech Research Corporation
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
// All rights reserved.
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
//
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
// This program is free software; you can redistribute it and/or modify
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
// it under the terms of the GNU General Public License version 2 as
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
// published by the Free Software Foundation;
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
//
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
// This program is distributed in the hope that it will be useful,
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
// GNU General Public License for more details.
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
//
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
// You should have received a copy of the GNU General Public License
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
// along with this program; if not, write to the Free Software
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
//
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
// Author: George F. Riley<riley@ece.gatech.edu>
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
//
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
// Define the basic Node object for ns3.
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
// George F. Riley, Georgia Tech, Fall 2006
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
361
9b159ff6dbcb Clean up parameter passing per TOm's request
George F. Riley<riley@ece.gatech.edu>
parents: 359
diff changeset
    25
#ifndef __NODE_H__
9b159ff6dbcb Clean up parameter passing per TOm's request
George F. Riley<riley@ece.gatech.edu>
parents: 359
diff changeset
    26
#define __NODE_H__
232
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    28
#include <vector>
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    29
512
5404e1e41f82 make Node derive from NsUnknown rather than Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 484
diff changeset
    30
#include "ns3/ns-unknown.h"
355
d18da75542c7 Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    31
232
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
namespace ns3 {
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
381
83b52d112c99 Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents: 361
diff changeset
    34
class ApplicationList;
241
9004ab4cfe17 add Ipv4 and Udp node capabilities, rework Copy methods to include an extra Node * argument
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 234
diff changeset
    35
class Ipv4;
9004ab4cfe17 add Ipv4 and Udp node capabilities, rework Copy methods to include an extra Node * argument
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 234
diff changeset
    36
class Udp;
242
a44932709b47 add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
    37
class Arp;
381
83b52d112c99 Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents: 361
diff changeset
    38
345
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 244
diff changeset
    39
class TraceContext;
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 244
diff changeset
    40
class TraceResolver;
447
180117abfb04 add NetDevice list into Node base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 381
diff changeset
    41
class NetDevice;
232
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    42
512
5404e1e41f82 make Node derive from NsUnknown rather than Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 484
diff changeset
    43
class Node : public NsUnknown
484
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 482
diff changeset
    44
{
512
5404e1e41f82 make Node derive from NsUnknown rather than Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 484
diff changeset
    45
public:
5404e1e41f82 make Node derive from NsUnknown rather than Object
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 484
diff changeset
    46
  static const uint32_t iid;
361
9b159ff6dbcb Clean up parameter passing per TOm's request
George F. Riley<riley@ece.gatech.edu>
parents: 359
diff changeset
    47
232
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    48
  Node();
355
d18da75542c7 Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    49
  Node(uint32_t); // Specify which system for a distributed simulation
232
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    50
  virtual ~Node();
244
caff04d90a66 remove SetNodeId and implement GetId and GetSystemId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
    51
345
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 244
diff changeset
    52
  virtual TraceResolver *CreateTraceResolver (TraceContext const &context) = 0;
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 244
diff changeset
    53
244
caff04d90a66 remove SetNodeId and implement GetId and GetSystemId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
    54
  uint32_t GetId (void) const;
caff04d90a66 remove SetNodeId and implement GetId and GetSystemId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
    55
  uint32_t GetSystemId (void) const;
caff04d90a66 remove SetNodeId and implement GetId and GetSystemId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
    56
  void SetSystemId(uint32_t s);
232
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    57
447
180117abfb04 add NetDevice list into Node base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 381
diff changeset
    58
  uint32_t AddDevice (NetDevice *device);
180117abfb04 add NetDevice list into Node base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 381
diff changeset
    59
  NetDevice *GetDevice (uint32_t index) const;
180117abfb04 add NetDevice list into Node base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 381
diff changeset
    60
  uint32_t GetNDevices (void) const;
180117abfb04 add NetDevice list into Node base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 381
diff changeset
    61
513
b7c7ea629de9 make L3Demux an NsUnknown object.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 512
diff changeset
    62
protected:
b7c7ea629de9 make L3Demux an NsUnknown object.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 512
diff changeset
    63
  virtual void DoDispose (void);
447
180117abfb04 add NetDevice list into Node base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 381
diff changeset
    64
private:
180117abfb04 add NetDevice list into Node base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 381
diff changeset
    65
  virtual void DoAddDevice (NetDevice *device) const = 0;
180117abfb04 add NetDevice list into Node base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 381
diff changeset
    66
355
d18da75542c7 Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    67
public:
232
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    68
  // Virtual "Getters" for each capability.
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    69
  // These exist to allow owners of a generic Node pointer to get
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    70
  // a pointer to the underlying capability, a pointer to a "NULL"
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    71
  // capability if one exists, or the nil pointer if not.
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    72
  // Each of these has a default behavior of returning a null capability
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    73
  // of the correct type if one exists, or the nil pointer if no
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    74
  // null capability exists.
381
83b52d112c99 Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents: 361
diff changeset
    75
  virtual ApplicationList* GetApplicationList() const;
241
9004ab4cfe17 add Ipv4 and Udp node capabilities, rework Copy methods to include an extra Node * argument
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 234
diff changeset
    76
  virtual Ipv4 *           GetIpv4 (void) const;
9004ab4cfe17 add Ipv4 and Udp node capabilities, rework Copy methods to include an extra Node * argument
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 234
diff changeset
    77
  virtual Udp *            GetUdp (void) const;
242
a44932709b47 add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
    78
  virtual Arp *            GetArp (void) const;
232
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    79
  
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    80
private:
244
caff04d90a66 remove SetNodeId and implement GetId and GetSystemId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
    81
  uint32_t    m_id;         // Node id for this node
caff04d90a66 remove SetNodeId and implement GetId and GetSystemId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
    82
  uint32_t    m_sid;        // System id for this node
447
180117abfb04 add NetDevice list into Node base class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 381
diff changeset
    83
  std::vector<NetDevice *> m_devices;
232
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    84
};
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    85
355
d18da75542c7 Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    86
} //namespace ns3
232
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    87
#endif