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)
144  (Ptr<const Packet> packet,
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 */
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::PointToPointChannel::TxRxAnimationCallback
void(* TxRxAnimationCallback)(Ptr< const Packet > packet, Ptr< NetDevice > txDevice, Ptr< NetDevice > rxDevice, Time duration, Time lastBitTime)
TracedCallback signature for packet transmission animation events.
Definition: point-to-point-channel.h:144
ns3::PointToPointChannel::Attach
void Attach(Ptr< PointToPointNetDevice > device)
Attach a given netdevice to this channel.
Definition: point-to-point-channel.cc:66
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::PointToPointChannel::GetTypeId
static TypeId GetTypeId(void)
Get the TypeId.
Definition: point-to-point-channel.cc:33
ns3::PointToPointChannel::IDLE
@ IDLE
Idle state (no transmission from NetDevice)
Definition: point-to-point-channel.h:181
ns3::PointToPointChannel::WireState
WireState
Wire states.
Definition: point-to-point-channel.h:177
ns3::PointToPointChannel
Simple Point To Point Channel.
Definition: point-to-point-channel.h:51
ns3::PointToPointChannel::m_delay
Time m_delay
Propagation delay.
Definition: point-to-point-channel.h:152
ns3::PointToPointChannel::GetDevice
virtual Ptr< NetDevice > GetDevice(std::size_t i) const
Get NetDevice corresponding to index i on this channel.
Definition: point-to-point-channel.cc:125
ns3::PointToPointChannel::INITIALIZING
@ INITIALIZING
Initializing state.
Definition: point-to-point-channel.h:179
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
ns3::PointToPointChannel::GetNDevices
virtual std::size_t GetNDevices(void) const
Get number of devices on this channel.
Definition: point-to-point-channel.cc:110
ns3::PointToPointChannel::GetDelay
Time GetDelay(void) const
Get the delay associated with this channel.
Definition: point-to-point-channel.cc:132
ns3::PointToPointChannel::m_txrxPointToPoint
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.
Definition: point-to-point-channel.h:171
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::PointToPointChannel::GetPointToPointDevice
Ptr< PointToPointNetDevice > GetPointToPointDevice(std::size_t i) const
Get PointToPointNetDevice corresponding to index i on this channel.
Definition: point-to-point-channel.cc:117
ns3::PointToPointChannel::TRANSMITTING
@ TRANSMITTING
Transmitting state (data being transmitted from NetDevice.
Definition: point-to-point-channel.h:183
ns3::PointToPointChannel::PROPAGATING
@ PROPAGATING
Propagating state (data is being propagated in the channel.
Definition: point-to-point-channel.h:185
ns3::PointToPointChannel::GetDestination
Ptr< PointToPointNetDevice > GetDestination(uint32_t i) const
Get the net-device destination.
Definition: point-to-point-channel.cc:144
ns3::PointToPointChannel::m_nDevices
std::size_t m_nDevices
Devices of this channel.
Definition: point-to-point-channel.h:153
ns3::PointToPointChannel::PointToPointChannel
PointToPointChannel()
Create a PointToPointChannel.
Definition: point-to-point-channel.cc:56
ns3::PointToPointChannel::IsInitialized
bool IsInitialized(void) const
Check to make sure the link is initialized.
Definition: point-to-point-channel.cc:150
ns3::Channel
Abstract Channel Base Class.
Definition: channel.h:44
ns3::PointToPointChannel::N_DEVICES
static const std::size_t N_DEVICES
Each point to point link has exactly two net devices.
Definition: point-to-point-channel.h:150
ns3::TracedValueCallback::Time
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition: nstime.h:813
ns3::TracedCallback
Forward calls to a chain of Callback.
Definition: traced-callback.h:53
ns3::PointToPointChannel::GetSource
Ptr< PointToPointNetDevice > GetSource(uint32_t i) const
Get the net-device source.
Definition: point-to-point-channel.cc:138
ns3::PointToPointChannel::TransmitStart
virtual bool TransmitStart(Ptr< const Packet > p, Ptr< PointToPointNetDevice > src, Time txTime)
Transmit a packet over this channel.
Definition: point-to-point-channel.cc:87
ns3::PointToPointChannel::m_link
Link m_link[N_DEVICES]
Link model.
Definition: point-to-point-channel.h:204