A Discrete-Event Network Simulator
API
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 
51 {
52 public:
58  static TypeId GetTypeId (void);
59 
67 
72  void Attach (Ptr<PointToPointNetDevice> device);
73 
81  virtual bool TransmitStart (Ptr<const Packet> p, Ptr<PointToPointNetDevice> src, Time txTime);
82 
87  virtual std::size_t GetNDevices (void) const;
88 
95 
101  virtual Ptr<NetDevice> GetDevice (std::size_t i) const;
102 
103 protected:
108  Time GetDelay (void) const;
109 
114  bool IsInitialized (void) const;
115 
122  Ptr<PointToPointNetDevice> GetSource (uint32_t i) const;
123 
130  Ptr<PointToPointNetDevice> GetDestination (uint32_t i) const;
131 
143  typedef void (* TxRxAnimationCallback)
145  Ptr<NetDevice> txDevice, Ptr<NetDevice> rxDevice,
146  Time duration, Time lastBitTime);
147 
148 private:
150  static const std::size_t N_DEVICES = 2;
151 
153  std::size_t m_nDevices;
154 
166  TracedCallback<Ptr<const Packet>, // Packet being transmitted
167  Ptr<NetDevice>, // Transmitting NetDevice
168  Ptr<NetDevice>, // Receiving NetDevice
169  Time, // Amount of time to transmit the pkt
170  Time // Last bit receive time (relative to now)
172 
177  {
186  };
187 
191  class Link
192  {
193 public:
197  Link() : m_state (INITIALIZING), m_src (0), m_dst (0) {}
198 
202  };
203 
205 };
206 
207 } // namespace ns3
208 
209 #endif /* POINT_TO_POINT_CHANNEL_H */
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
virtual bool TransmitStart(Ptr< const Packet > p, Ptr< PointToPointNetDevice > src, Time txTime)
Transmit a packet over this channel.
Ptr< PointToPointNetDevice > GetDestination(uint32_t i) const
Get the net-device destination.
Forward calls to a chain of Callback.
Link m_link[N_DEVICES]
Link model.
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...
static TypeId GetTypeId(void)
Get the TypeId.
virtual Ptr< NetDevice > GetDevice(std::size_t i) const
Get NetDevice corresponding to index i on this channel.
Abstract Channel Base Class.
Definition: channel.h:43
Time GetDelay(void) const
Get the delay associated with this channel.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition: nstime.h:740
void Attach(Ptr< PointToPointNetDevice > device)
Attach a given netdevice to this channel.
Propagating state (data is being propagated in the channel.
Time m_delay
Propagation delay.
bool IsInitialized(void) const
Check to make sure the link is initialized.
PointToPointChannel()
Create a PointToPointChannel.
std::size_t m_nDevices
Devices of this channel.
Ptr< PointToPointNetDevice > GetPointToPointDevice(std::size_t i) const
Get PointToPointNetDevice corresponding to index i on this channel.
static const std::size_t N_DEVICES
Each point to point link has exactly two net devices.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Transmitting state (data being transmitted from NetDevice.
virtual std::size_t GetNDevices(void) const
Get number of devices on this channel.
Ptr< PointToPointNetDevice > GetSource(uint32_t i) const
Get the net-device source.
Simple Point To Point Channel.
Idle state (no transmission from NetDevice)
void(* TxRxAnimationCallback)(Ptr< const Packet > packet, Ptr< NetDevice > txDevice, Ptr< NetDevice > rxDevice, Time duration, Time lastBitTime)
TracedCallback signature for packet transmission animation events.
a unique identifier for an interface.
Definition: type-id.h:58