A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
point-to-point-remote-channel.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2007, 2008 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
* Author: George Riley <riley@ece.gatech.edu>
19
*/
20
21
#include <iostream>
22
23
#include "
point-to-point-remote-channel.h
"
24
#include "
point-to-point-net-device.h
"
25
#include "ns3/packet.h"
26
#include "ns3/simulator.h"
27
#include "ns3/log.h"
28
#include "ns3/mpi-interface.h"
29
30
namespace
ns3
{
31
32
NS_LOG_COMPONENT_DEFINE
(
"PointToPointRemoteChannel"
);
33
34
NS_OBJECT_ENSURE_REGISTERED
(PointToPointRemoteChannel);
35
36
TypeId
37
PointToPointRemoteChannel::GetTypeId
(
void
)
38
{
39
static
TypeId
tid =
TypeId
(
"ns3::PointToPointRemoteChannel"
)
40
.
SetParent
<
PointToPointChannel
> ()
41
.SetGroupName (
"PointToPoint"
)
42
.AddConstructor<
PointToPointRemoteChannel
> ()
43
;
44
return
tid;
45
}
46
47
PointToPointRemoteChannel::PointToPointRemoteChannel
()
48
{
49
}
50
51
PointToPointRemoteChannel::~PointToPointRemoteChannel
()
52
{
53
}
54
55
bool
56
PointToPointRemoteChannel::TransmitStart
(
57
Ptr<Packet>
p,
58
Ptr<PointToPointNetDevice>
src,
59
Time
txTime)
60
{
61
NS_LOG_FUNCTION
(
this
<< p << src);
62
NS_LOG_LOGIC
(
"UID is "
<< p->
GetUid
() <<
")"
);
63
64
IsInitialized
();
65
66
uint32_t wire = src ==
GetSource
(0) ? 0 : 1;
67
Ptr<PointToPointNetDevice>
dst =
GetDestination
(wire);
68
69
#ifdef NS3_MPI
70
// Calculate the rxTime (absolute)
71
Time
rxTime =
Simulator::Now
() + txTime +
GetDelay
();
72
MpiInterface::SendPacket
(p, rxTime, dst->GetNode ()->GetId (), dst->GetIfIndex ());
73
#else
74
NS_FATAL_ERROR
(
"Can't use distributed simulator without MPI compiled in"
);
75
#endif
76
return
true
;
77
}
78
79
}
// namespace ns3
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition:
nstime.h:102
ns3::Ptr< Packet >
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Definition:
log-macros-enabled.h:213
ns3::PointToPointRemoteChannel::TransmitStart
virtual bool TransmitStart(Ptr< Packet > p, Ptr< PointToPointNetDevice > src, Time txTime)
Transmit the packet.
Definition:
point-to-point-remote-channel.cc:56
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:44
ns3::PointToPointChannel::IsInitialized
bool IsInitialized(void) const
Check to make sure the link is initialized.
Definition:
point-to-point-channel.cc:150
ns3::Packet::GetUid
uint64_t GetUid(void) const
Returns the packet's Uid.
Definition:
packet.cc:380
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:201
NS_FATAL_ERROR
#define NS_FATAL_ERROR(msg)
Fatal error handling.
Definition:
fatal-error.h:100
ns3::PointToPointRemoteChannel::~PointToPointRemoteChannel
~PointToPointRemoteChannel()
Deconstructor.
Definition:
point-to-point-remote-channel.cc:51
ns3::PointToPointRemoteChannel
A Remote Point-To-Point Channel.
Definition:
point-to-point-remote-channel.h:41
ns3::PointToPointChannel::GetDelay
Time GetDelay(void) const
Get the delay associated with this channel.
Definition:
point-to-point-channel.cc:132
NS_LOG_LOGIC
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition:
log.h:252
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::PointToPointRemoteChannel::GetTypeId
static TypeId GetTypeId(void)
Get the TypeId.
Definition:
point-to-point-remote-channel.cc:37
point-to-point-remote-channel.h
point-to-point-net-device.h
ns3::Simulator::Now
static Time Now(void)
Return the current simulation virtual time.
Definition:
simulator.cc:223
ns3::PointToPointRemoteChannel::PointToPointRemoteChannel
PointToPointRemoteChannel()
Constructor.
Definition:
point-to-point-remote-channel.cc:47
ns3::MpiInterface::SendPacket
static void SendPacket(Ptr< Packet > p, const Time &rxTime, uint32_t node, uint32_t dev)
Definition:
mpi-interface.cc:112
ns3::PointToPointChannel
Simple Point To Point Channel.
Definition:
point-to-point-channel.h:50
ns3::PointToPointChannel::GetSource
Ptr< PointToPointNetDevice > GetSource(uint32_t i) const
Get the net-device source.
Definition:
point-to-point-channel.cc:138
ns3::PointToPointChannel::GetDestination
Ptr< PointToPointNetDevice > GetDestination(uint32_t i) const
Get the net-device destination.
Definition:
point-to-point-channel.cc:144
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:57
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Definition:
type-id.cc:638
src
point-to-point
model
point-to-point-remote-channel.cc
Generated on Wed May 13 2015 14:59:29 for ns-3 by
1.8.9.1