src/helper/emu-helper.cc
author Craig Dowell <craigdo@ee.washington.edu>
Fri, 12 Feb 2010 17:31:11 -0800
changeset 6049 3dbc035a9ee4
parent 6028 96fb92f73f3d
child 6052 e146b9c9c7e7
permissions -rw-r--r--
The name OutputStreamObject is no longer appropriate
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     2
/*
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     3
 * Copyright (c) 2008 University of Washington
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     4
 *
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     8
 *
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    12
 * GNU General Public License for more details.
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    13
 *
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    17
 */
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    18
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    19
#include <string>
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    20
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    21
#include "ns3/log.h"
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    22
#include "ns3/simulator.h"
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    23
#include "ns3/object-factory.h"
4147
5d8530130930 rename object-names.{cc,h} to names.{cc,h} per convention
Craig Dowell <craigdo@ee.washington.edu>
parents: 4140
diff changeset
    24
#include "ns3/names.h"
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    25
#include "ns3/queue.h"
3830
8862b9be62bb rework to address suid root issues
Craig Dowell <craigdo@ee.washington.edu>
parents: 3828
diff changeset
    26
#include "ns3/emu-net-device.h"
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    27
#include "ns3/config.h"
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    28
#include "ns3/packet.h"
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    29
6028
96fb92f73f3d merge trace helpers, rescan
Craig Dowell <craigdo@ee.washington.edu>
parents: 6013
diff changeset
    30
#include "trace-helper.h"
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    31
#include "emu-helper.h"
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    32
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    33
NS_LOG_COMPONENT_DEFINE ("EmuHelper");
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    34
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    35
namespace ns3 {
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    36
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    37
EmuHelper::EmuHelper ()
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    38
{
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    39
  NS_LOG_FUNCTION_NOARGS ();
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    40
  m_queueFactory.SetTypeId ("ns3::DropTailQueue");
3830
8862b9be62bb rework to address suid root issues
Craig Dowell <craigdo@ee.washington.edu>
parents: 3828
diff changeset
    41
  m_deviceFactory.SetTypeId ("ns3::EmuNetDevice");
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    42
}
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    43
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
    44
void 
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    45
EmuHelper::SetQueue (
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    46
  std::string type,
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    47
  std::string n1, const AttributeValue &v1,
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    48
  std::string n2, const AttributeValue &v2,
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    49
  std::string n3, const AttributeValue &v3,
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    50
  std::string n4, const AttributeValue &v4)
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    51
{
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    52
  NS_LOG_FUNCTION_NOARGS ();
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    53
  m_queueFactory.SetTypeId (type);
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    54
  m_queueFactory.Set (n1, v1);
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    55
  m_queueFactory.Set (n2, v2);
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    56
  m_queueFactory.Set (n3, v3);
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    57
  m_queueFactory.Set (n4, v4);
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    58
}
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    59
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
    60
void 
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    61
EmuHelper::SetAttribute (std::string n1, const AttributeValue &v1)
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    62
{
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    63
  NS_LOG_FUNCTION_NOARGS ();
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    64
  m_deviceFactory.Set (n1, v1);
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    65
}
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    66
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
    67
void 
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4712
diff changeset
    68
EmuHelper::EnablePcapInternal (std::string prefix, Ptr<NetDevice> nd, bool promiscuous)
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    69
{
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4712
diff changeset
    70
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4712
diff changeset
    71
  // All of the Pcap enable functions vector through here including the ones
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4712
diff changeset
    72
  // that are wandering through all of devices on perhaps all of the nodes in
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4712
diff changeset
    73
  // the system.  We can only deal with devices of type EmuNetDevice.
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4712
diff changeset
    74
  //
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4712
diff changeset
    75
  Ptr<EmuNetDevice> device = nd->GetObject<EmuNetDevice> ();
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4712
diff changeset
    76
  if (device == 0)
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4712
diff changeset
    77
    {
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4712
diff changeset
    78
      NS_LOG_INFO ("EmuHelper::EnablePcapInternal(): Device " << device << " not of type ns3::EmuNetDevice");
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4712
diff changeset
    79
      return;
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4712
diff changeset
    80
    }
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    81
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4712
diff changeset
    82
  PcapHelper pcapHelper;
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
    83
  std::string filename = pcapHelper.GetFilenameFromDevice (prefix, device);
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4712
diff changeset
    84
  Ptr<PcapFileObject> file = pcapHelper.CreateFile (filename, "w", PcapHelper::DLT_EN10MB);
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
    85
  if (promiscuous)
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
    86
    {
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4712
diff changeset
    87
      pcapHelper.HookDefaultSink<EmuNetDevice> (device, "PromiscSniffer", file);
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
    88
    }
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
    89
  else
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
    90
    {
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 4712
diff changeset
    91
      pcapHelper.HookDefaultSink<EmuNetDevice> (device, "Sniffer", file);
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
    92
    }
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    93
}
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    94
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
    95
void 
6049
3dbc035a9ee4 The name OutputStreamObject is no longer appropriate
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
    96
EmuHelper::EnableAsciiInternal (Ptr<OutputStreamKeeper> stream, std::string prefix, Ptr<NetDevice> nd)
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    97
{
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
    98
  //
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
    99
  // All of the ascii enable functions vector through here including the ones
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   100
  // that are wandering through all of devices on perhaps all of the nodes in
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   101
  // the system.  We can only deal with devices of type EmuNetDevice.
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   102
  //
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   103
  Ptr<EmuNetDevice> device = nd->GetObject<EmuNetDevice> ();
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   104
  if (device == 0)
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   105
    {
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   106
      NS_LOG_INFO ("EmuHelper::EnableAsciiInternal(): Device " << device << " not of type ns3::EmuNetDevice");
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   107
      return;
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   108
    }
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   109
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   110
  //
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   111
  // Our default trace sinks are going to use packet printing, so we have to 
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   112
  // make sure that is turned on.
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   113
  //
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   114
  Packet::EnablePrinting ();
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   115
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   116
  //
6049
3dbc035a9ee4 The name OutputStreamObject is no longer appropriate
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   117
  // If we are not provided an OutputStreamKeeper, we are expected to create 
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   118
  // one using the usual trace filename conventions and do a Hook*WithoutContext
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   119
  // since there will be one file per context and therefore the context would
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   120
  // be redundant.
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   121
  //
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   122
  if (stream == 0)
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   123
    {
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   124
      //
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   125
      // Set up an output stream object to deal with private ofstream copy 
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   126
      // constructor and lifetime issues.  Let the helper decide the actual
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   127
      // name of the file given the prefix.
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   128
      //
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   129
      AsciiTraceHelper asciiTraceHelper;
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   130
      std::string filename = asciiTraceHelper.GetFilenameFromDevice (prefix, device);
6049
3dbc035a9ee4 The name OutputStreamObject is no longer appropriate
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   131
      Ptr<OutputStreamKeeper> theStream = asciiTraceHelper.CreateFileStream (filename, "w");
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   132
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   133
      //
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   134
      // The MacRx trace source provides our "r" event.
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   135
      //
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   136
      asciiTraceHelper.HookDefaultReceiveSinkWithoutContext<EmuNetDevice> (device, "MacRx", theStream);
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   137
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   138
      //
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   139
      // The "+", '-', and 'd' events are driven by trace sources actually in the
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   140
      // transmit queue.
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   141
      //
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   142
      Ptr<Queue> queue = device->GetQueue ();
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   143
      asciiTraceHelper.HookDefaultEnqueueSinkWithoutContext<Queue> (queue, "Enqueue", theStream);
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   144
      asciiTraceHelper.HookDefaultDropSinkWithoutContext<Queue> (queue, "Drop", theStream);
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   145
      asciiTraceHelper.HookDefaultDequeueSinkWithoutContext<Queue> (queue, "Dequeue", theStream);
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   146
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   147
      return;
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   148
    }
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   149
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   150
  //
6049
3dbc035a9ee4 The name OutputStreamObject is no longer appropriate
Craig Dowell <craigdo@ee.washington.edu>
parents: 6028
diff changeset
   151
  // If we are provided an OutputStreamKeeper, we are expected to use it, and
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   152
  // to providd a context.  We are free to come up with our own context if we
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   153
  // want, and use the AsciiTraceHelper Hook*WithContext functions, but for 
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   154
  // compatibility and simplicity, we just use Config::Connect and let it deal
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   155
  // with the context.
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   156
  //
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   157
  // Note that we are going to use the default trace sinks provided by the 
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   158
  // ascii trace helper.  There is actually no AsciiTraceHelper in sight here,
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   159
  // but the default trace sinks are actually publicly available static 
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   160
  // functions that are always there waiting for just such a case.
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   161
  //
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   162
  uint32_t nodeid = nd->GetNode ()->GetId ();
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   163
  uint32_t deviceid = nd->GetIfIndex ();
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   164
  std::ostringstream oss;
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   165
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   166
  oss << "/NodeList/" << nd->GetNode ()->GetId () << "/DeviceList/" << deviceid << "/$ns3::EmuNetDevice/MacRx";
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   167
  Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultReceiveSinkWithContext, stream));
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   168
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   169
  oss.str ("");
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4147
diff changeset
   170
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::EmuNetDevice/TxQueue/Enqueue";
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   171
  Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultEnqueueSinkWithContext, stream));
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   172
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   173
  oss.str ("");
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4147
diff changeset
   174
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::EmuNetDevice/TxQueue/Dequeue";
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   175
  Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultDequeueSinkWithContext, stream));
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   176
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   177
  oss.str ("");
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4147
diff changeset
   178
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::EmuNetDevice/TxQueue/Drop";
6013
fa3ab7f34eb2 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   179
  Config::Connect (oss.str (), MakeBoundCallback (&AsciiTraceHelper::DefaultDropSinkWithContext, stream));
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   180
}
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   181
3848
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   182
NetDeviceContainer
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   183
EmuHelper::Install (Ptr<Node> node) const
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   184
{
3848
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   185
  return NetDeviceContainer (InstallPriv (node));
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   186
}
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   187
4140
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
   188
NetDeviceContainer
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
   189
EmuHelper::Install (std::string nodeName) const
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
   190
{
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
   191
  Ptr<Node> node = Names::Find<Node> (nodeName);
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
   192
  return NetDeviceContainer (InstallPriv (node));
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
   193
}
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
   194
3848
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   195
NetDeviceContainer 
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   196
EmuHelper::Install (const NodeContainer &c) const
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   197
{
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   198
  NetDeviceContainer devs;
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   199
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   200
  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); i++)
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   201
    {
3848
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   202
      devs.Add (InstallPriv (*i));
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   203
    }
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   204
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   205
  return devs;
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   206
}
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   207
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   208
Ptr<NetDevice>
3848
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   209
EmuHelper::InstallPriv (Ptr<Node> node) const
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   210
{
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   211
  Ptr<EmuNetDevice> device = m_deviceFactory.Create<EmuNetDevice> ();
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   212
  device->SetAddress (Mac48Address::Allocate ());
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   213
  node->AddDevice (device);
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   214
  Ptr<Queue> queue = m_queueFactory.Create<Queue> ();
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   215
  device->SetQueue (queue);
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   216
3848
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   217
  return device;
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   218
}
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   219
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   220
} // namespace ns3