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
29namespace ns3 {
30
31class PointToPointNetDevice;
32class Packet;
33
51{
52public:
58 static TypeId GetTypeId (void);
59
67
73
82
87 virtual std::size_t GetNDevices (void) const;
88
95
101 virtual Ptr<NetDevice> GetDevice (std::size_t i) const;
102
103protected:
108 Time GetDelay (void) const;
109
114 bool IsInitialized (void) const;
115
123
131
143 typedef void (* TxRxAnimationCallback)
144 (Ptr<const Packet> packet,
145 Ptr<NetDevice> txDevice, Ptr<NetDevice> rxDevice,
146 Time duration, Time lastBitTime);
147
148private:
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 {
193public:
198
202 };
203
205};
206
207} // namespace ns3
208
209#endif /* POINT_TO_POINT_CHANNEL_H */
Abstract Channel Base Class.
Definition: channel.h:44
Simple Point To Point Channel.
virtual std::size_t GetNDevices(void) const
Get number of devices on this channel.
Link m_link[N_DEVICES]
Link model.
std::size_t m_nDevices
Devices of this channel.
void Attach(Ptr< PointToPointNetDevice > device)
Attach a given netdevice to this channel.
Ptr< PointToPointNetDevice > GetSource(uint32_t i) const
Get the net-device source.
PointToPointChannel()
Create a PointToPointChannel.
Ptr< PointToPointNetDevice > GetDestination(uint32_t i) const
Get the net-device destination.
@ PROPAGATING
Propagating state (data is being propagated in the channel.
@ TRANSMITTING
Transmitting state (data being transmitted from NetDevice.
@ IDLE
Idle state (no transmission from NetDevice)
@ INITIALIZING
Initializing state.
Ptr< PointToPointNetDevice > GetPointToPointDevice(std::size_t i) const
Get PointToPointNetDevice corresponding to index i on this channel.
bool IsInitialized(void) const
Check to make sure the link is initialized.
Time GetDelay(void) const
Get the delay associated with this channel.
static TypeId GetTypeId(void)
Get the TypeId.
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.
Time m_delay
Propagation delay.
virtual bool TransmitStart(Ptr< const Packet > p, Ptr< PointToPointNetDevice > src, Time txTime)
Transmit a packet over this channel.
virtual Ptr< NetDevice > GetDevice(std::size_t i) const
Get NetDevice corresponding to index i on this channel.
static const std::size_t N_DEVICES
Each point to point link has exactly two net devices.
void(* TxRxAnimationCallback)(Ptr< const Packet > packet, Ptr< NetDevice > txDevice, Ptr< NetDevice > rxDevice, Time duration, Time lastBitTime)
TracedCallback signature for packet transmission animation events.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition: nstime.h:793
Every class exported by the ns3 library is enclosed in the ns3 namespace.