A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
point-to-point-remote-channel.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2007, 2008 University of Washington
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: George Riley <riley@ece.gatech.edu>
18
*/
19
20
#include "
point-to-point-remote-channel.h
"
21
22
#include "
point-to-point-net-device.h
"
23
24
#include "ns3/log.h"
25
#include "ns3/mpi-interface.h"
26
#include "ns3/packet.h"
27
#include "ns3/simulator.h"
28
29
#include <iostream>
30
31
namespace
ns3
32
{
33
34
NS_LOG_COMPONENT_DEFINE
(
"PointToPointRemoteChannel"
);
35
36
NS_OBJECT_ENSURE_REGISTERED
(PointToPointRemoteChannel);
37
38
TypeId
39
PointToPointRemoteChannel::GetTypeId
()
40
{
41
static
TypeId
tid =
TypeId
(
"ns3::PointToPointRemoteChannel"
)
42
.
SetParent
<
PointToPointChannel
>()
43
.SetGroupName(
"PointToPoint"
)
44
.AddConstructor<
PointToPointRemoteChannel
>();
45
return
tid;
46
}
47
48
PointToPointRemoteChannel::PointToPointRemoteChannel
()
49
:
PointToPointChannel
()
50
{
51
}
52
53
PointToPointRemoteChannel::~PointToPointRemoteChannel
()
54
{
55
}
56
57
bool
58
PointToPointRemoteChannel::TransmitStart
(
Ptr<const Packet>
p,
59
Ptr<PointToPointNetDevice>
src,
60
Time
txTime)
61
{
62
NS_LOG_FUNCTION
(
this
<< p << src);
63
NS_LOG_LOGIC
(
"UID is "
<< p->
GetUid
() <<
")"
);
64
65
IsInitialized
();
66
67
uint32_t wire = src ==
GetSource
(0) ? 0 : 1;
68
Ptr<PointToPointNetDevice>
dst =
GetDestination
(wire);
69
70
// Calculate the rxTime (absolute)
71
Time
rxTime =
Simulator::Now
() + txTime +
GetDelay
();
72
MpiInterface::SendPacket
(p->
Copy
(), rxTime, dst->GetNode()->GetId(), dst->GetIfIndex());
73
return
true
;
74
}
75
76
}
// namespace ns3
ns3::MpiInterface::SendPacket
static void SendPacket(Ptr< Packet > p, const Time &rxTime, uint32_t node, uint32_t dev)
Send a packet to a remote node.
Definition:
mpi-interface.cc:139
ns3::Packet::Copy
Ptr< Packet > Copy() const
performs a COW copy of the packet.
Definition:
packet.cc:131
ns3::Packet::GetUid
uint64_t GetUid() const
Returns the packet's Uid.
Definition:
packet.cc:412
ns3::PointToPointChannel
Simple Point To Point Channel.
Definition:
point-to-point-channel.h:52
ns3::PointToPointChannel::GetDelay
Time GetDelay() const
Get the delay associated with this channel.
Definition:
point-to-point-channel.cc:133
ns3::PointToPointChannel::GetSource
Ptr< PointToPointNetDevice > GetSource(uint32_t i) const
Get the net-device source.
Definition:
point-to-point-channel.cc:139
ns3::PointToPointChannel::GetDestination
Ptr< PointToPointNetDevice > GetDestination(uint32_t i) const
Get the net-device destination.
Definition:
point-to-point-channel.cc:145
ns3::PointToPointChannel::IsInitialized
bool IsInitialized() const
Check to make sure the link is initialized.
Definition:
point-to-point-channel.cc:151
ns3::PointToPointRemoteChannel
A Remote Point-To-Point Channel.
Definition:
point-to-point-remote-channel.h:42
ns3::PointToPointRemoteChannel::TransmitStart
bool TransmitStart(Ptr< const Packet > p, Ptr< PointToPointNetDevice > src, Time txTime) override
Transmit the packet.
Definition:
point-to-point-remote-channel.cc:58
ns3::PointToPointRemoteChannel::~PointToPointRemoteChannel
~PointToPointRemoteChannel() override
Deconstructor.
Definition:
point-to-point-remote-channel.cc:53
ns3::PointToPointRemoteChannel::GetTypeId
static TypeId GetTypeId()
Get the TypeId.
Definition:
point-to-point-remote-channel.cc:39
ns3::PointToPointRemoteChannel::PointToPointRemoteChannel
PointToPointRemoteChannel()
Constructor.
Definition:
point-to-point-remote-channel.cc:48
ns3::Ptr< const Packet >
ns3::Simulator::Now
static Time Now()
Return the current simulation virtual time.
Definition:
simulator.cc:208
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition:
nstime.h:105
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:931
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
NS_LOG_LOGIC
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition:
log.h:282
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:240
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:46
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
point-to-point-net-device.h
point-to-point-remote-channel.h
src
point-to-point
model
point-to-point-remote-channel.cc
Generated on Sun Mar 3 2024 17:11:07 for ns-3 by
1.9.1