A Discrete-Event Network Simulator
API
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 
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
38 {
39  static TypeId tid = TypeId ("ns3::PointToPointRemoteChannel")
41  .SetGroupName ("PointToPoint")
42  .AddConstructor<PointToPointRemoteChannel> ()
43  ;
44  return tid;
45 }
46 
49 {
50 }
51 
53 {
54 }
55 
56 bool
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;
69 
70 #ifdef NS3_MPI
71  // Calculate the rxTime (absolute)
72  Time rxTime = Simulator::Now () + txTime + GetDelay ();
73  MpiInterface::SendPacket (p->Copy (), rxTime, dst->GetNode ()->GetId (), dst->GetIfIndex ());
74 #else
75  NS_FATAL_ERROR ("Can't use distributed simulator without MPI compiled in");
76 #endif
77  return true;
78 }
79 
80 } // namespace ns3
uint64_t GetUid(void) const
Returns the packet&#39;s Uid.
Definition: packet.cc:390
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Ptr< PointToPointNetDevice > GetDestination(uint32_t i) const
Get the net-device destination.
virtual bool TransmitStart(Ptr< const Packet > p, Ptr< PointToPointNetDevice > src, Time txTime)
Transmit the packet.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
Time GetDelay(void) const
Get the delay associated with this channel.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
bool IsInitialized(void) const
Check to make sure the link is initialized.
A Remote Point-To-Point Channel.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static TypeId GetTypeId(void)
Get the TypeId.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:193
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
Ptr< PointToPointNetDevice > GetSource(uint32_t i) const
Get the net-device source.
static void SendPacket(Ptr< Packet > p, const Time &rxTime, uint32_t node, uint32_t dev)
Simple Point To Point Channel.
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923