A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
point-to-point-channel.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007 University of Washington
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 
19 #ifndef POINT_TO_POINT_CHANNEL_H
20 #define POINT_TO_POINT_CHANNEL_H
21 
22 #include <list>
23 #include "ns3/channel.h"
24 #include "ns3/ptr.h"
25 #include "ns3/nstime.h"
26 #include "ns3/data-rate.h"
27 #include "ns3/traced-callback.h"
28 
29 namespace ns3 {
30 
31 class PointToPointNetDevice;
32 class Packet;
33 
48 {
49 public:
50  static TypeId GetTypeId (void);
51 
59 
64  void Attach (Ptr<PointToPointNetDevice> device);
65 
73  virtual bool TransmitStart (Ptr<Packet> p, Ptr<PointToPointNetDevice> src, Time txTime);
74 
79  virtual uint32_t GetNDevices (void) const;
80 
81  /*
82  * \brief Get PointToPointNetDevice corresponding to index i on this channel
83  * \param i Index number of the device requested
84  * \returns Ptr to PointToPointNetDevice requested
85  */
87 
88  /*
89  * \brief Get NetDevice corresponding to index i on this channel
90  * \param i Index number of the device requested
91  * \returns Ptr to NetDevice requested
92  */
93  virtual Ptr<NetDevice> GetDevice (uint32_t i) const;
94 
95 protected:
96  /*
97  * \brief Get the delay associated with this channel
98  * \returns Time delay
99  */
100  Time GetDelay (void) const;
101 
102  /*
103  * \brief Check to make sure the link is initialized
104  * \returns true if initialized, asserts otherwise
105  */
106  bool IsInitialized (void) const;
107 
108  /*
109  * \brief Get the net-device source
110  * \param i the link requested
111  * \returns Ptr to PointToPointNetDevice source for the
112  * specified link
113  */
114  Ptr<PointToPointNetDevice> GetSource (uint32_t i) const;
115 
116  /*
117  * \brief Get the net-device destination
118  * \param i the link requested
119  * \returns Ptr to PointToPointNetDevice destination for
120  * the specified link
121  */
122  Ptr<PointToPointNetDevice> GetDestination (uint32_t i) const;
123 
124 private:
125  // Each point to point link has exactly two net devices
126  static const int N_DEVICES = 2;
127 
129  int32_t m_nDevices;
130 
140  TracedCallback<Ptr<const Packet>, // Packet being transmitted
141  Ptr<NetDevice>, // Transmitting NetDevice
142  Ptr<NetDevice>, // Receiving NetDevice
143  Time, // Amount of time to transmit the pkt
144  Time // Last bit receive time (relative to now)
146 
148  {
153  };
154 
155  class Link
156  {
157 public:
158  Link() : m_state (INITIALIZING), m_src (0), m_dst (0) {}
162  };
163 
165 };
166 
167 } // namespace ns3
168 
169 #endif /* POINT_TO_POINT_CHANNEL_H */
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
TracedCallback< Ptr< const Packet >, Ptr< NetDevice >, Ptr< NetDevice >, Time, Time > m_txrxPointToPoint
The trace source for the packet transmission animation events that the device can fire...
Abstract Channel Base Class.
Definition: channel.h:43
virtual uint32_t GetNDevices(void) const
Get number of devices on this channel.
void Attach(Ptr< PointToPointNetDevice > device)
Attach a given netdevice to this channel.
PointToPointChannel()
Create a PointToPointChannel.
virtual Ptr< NetDevice > GetDevice(uint32_t i) const
Simple Point To Point Channel.
Ptr< PointToPointNetDevice > GetSource(uint32_t i) const
virtual bool TransmitStart(Ptr< Packet > p, Ptr< PointToPointNetDevice > src, Time txTime)
Transmit a packet over this channel.
Ptr< PointToPointNetDevice > GetDestination(uint32_t i) const
a unique identifier for an interface.
Definition: type-id.h:49
Ptr< PointToPointNetDevice > GetPointToPointDevice(uint32_t i) const