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<Packet> p, Ptr<PointToPointNetDevice> src, Time txTime);
82 
87  virtual uint32_t GetNDevices (void) const;
88 
95 
101  virtual Ptr<NetDevice> GetDevice (uint32_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 
141  typedef void (* TxRxAnimationCallback)
142  (const Ptr<const Packet> packet,
143  const Ptr<const NetDevice> txDevice, const Ptr<const NetDevice> rxDevice,
144  const Time duration, const Time lastBitTime);
145 
146 private:
148  static const int N_DEVICES = 2;
149 
151  int32_t m_nDevices;
152 
162  TracedCallback<Ptr<const Packet>, // Packet being transmitted
163  Ptr<NetDevice>, // Transmitting NetDevice
164  Ptr<NetDevice>, // Receiving NetDevice
165  Time, // Amount of time to transmit the pkt
166  Time // Last bit receive time (relative to now)
168 
173  {
182  };
183 
187  class Link
188  {
189 public:
193  Link() : m_state (INITIALIZING), m_src (0), m_dst (0) {}
194 
198  };
199 
201 };
202 
203 } // namespace ns3
204 
205 #endif /* POINT_TO_POINT_CHANNEL_H */
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:95
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
Transmitting state (data being transmitted from NetDevice.
int32_t m_nDevices
Devices of this channel.
bool IsInitialized(void) const
Check to make sure the link is initialized.
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.
Idle state (no transmission from NetDevice)
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.
Time m_delay
Propagation delay.
PointToPointChannel()
Create a PointToPointChannel.
Time GetDelay(void) const
Get the delay associated with this channel.
void(* TxRxAnimationCallback)(const Ptr< const Packet > packet, const Ptr< const NetDevice > txDevice, const Ptr< const NetDevice > rxDevice, const Time duration, const Time lastBitTime)
TracedCallback signature for packet transmission animation events.
Propagating state (data is being propagated in the channel.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual Ptr< NetDevice > GetDevice(uint32_t i) const
Get NetDevice corresponding to index i on this channel.
Simple Point To Point Channel.
static const int N_DEVICES
Each point to point link has exactly two net devices.
Ptr< PointToPointNetDevice > GetSource(uint32_t i) const
Get the net-device source.
virtual bool TransmitStart(Ptr< 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.
a unique identifier for an interface.
Definition: type-id.h:51
Ptr< PointToPointNetDevice > GetPointToPointDevice(uint32_t i) const
Get PointToPointNetDevice corresponding to index i on this channel.