A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 NS_LOG_COMPONENT_DEFINE ("PointToPointRemoteChannel");
31 
32 namespace ns3 {
33 
34 NS_OBJECT_ENSURE_REGISTERED (PointToPointRemoteChannel);
35 
36 TypeId
38 {
39  static TypeId tid = TypeId ("ns3::PointToPointRemoteChannel")
41  .AddConstructor<PointToPointRemoteChannel> ()
42  ;
43  return tid;
44 }
45 
47 {
48 }
49 
51 {
52 }
53 
54 bool
56  Ptr<Packet> p,
58  Time txTime)
59 {
60  NS_LOG_FUNCTION (this << p << src);
61  NS_LOG_LOGIC ("UID is " << p->GetUid () << ")");
62 
63  IsInitialized ();
64 
65  uint32_t wire = src == GetSource (0) ? 0 : 1;
67 
68 #ifdef NS3_MPI
69  // Calculate the rxTime (absolute)
70  Time rxTime = Simulator::Now () + txTime + GetDelay ();
71  MpiInterface::SendPacket (p, rxTime, dst->GetNode ()->GetId (), dst->GetIfIndex ());
72 #else
73  NS_FATAL_ERROR ("Can't use distributed simulator without MPI compiled in");
74 #endif
75  return true;
76 }
77 
78 } // namespace ns3
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:79
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
virtual bool TransmitStart(Ptr< Packet > p, Ptr< PointToPointNetDevice > src, Time txTime)
Transmit a packet over this channel.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
uint64_t GetUid(void) const
Returns the packet's Uid.
Definition: packet.cc:393
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:95
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:233
static Time Now(void)
Return the "current simulation time".
Definition: simulator.cc:180
static void SendPacket(Ptr< Packet > p, const Time &rxTime, uint32_t node, uint32_t dev)
Simple Point To Point Channel.
Ptr< PointToPointNetDevice > GetSource(uint32_t i) const
Ptr< PointToPointNetDevice > GetDestination(uint32_t i) const
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610