src/helper/emu-helper.cc
author Craig Dowell <craigdo@ee.washington.edu>
Sat, 28 Feb 2009 16:25:24 -0800
changeset 4263 fec2f830d015
parent 4147 5d8530130930
child 4264 9d2e96c4e6e4
permissions -rw-r--r--
trace consistency changes
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/pcap-writer.h"
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    28
#include "ns3/config.h"
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    29
#include "ns3/packet.h"
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    30
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
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    44
  void 
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
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    60
  void 
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
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    67
  void 
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    68
EmuHelper::EnablePcap (
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    69
  std::string filename, 
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    70
  uint32_t nodeid, 
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    71
  uint32_t deviceid)
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    72
{
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    73
  NS_LOG_FUNCTION (filename << nodeid << deviceid);
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    74
  std::ostringstream oss;
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    75
  oss << filename << "-" << nodeid << "-" << deviceid << ".pcap";
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    76
  Ptr<PcapWriter> pcap = Create<PcapWriter> ();
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    77
  pcap->Open (oss.str ());
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    78
  pcap->WriteEthernetHeader ();
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    79
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    80
  oss.str ("");
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4147
diff changeset
    81
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::EmuNetDevice/Sniffer";
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4147
diff changeset
    82
  Config::ConnectWithoutContext (oss.str (), MakeBoundCallback (&EmuHelper::SniffEvent, pcap));
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    83
}
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    84
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    85
  void 
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    86
EmuHelper::EnablePcap (std::string filename, NetDeviceContainer d)
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    87
{
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    88
  NS_LOG_FUNCTION (filename << &d);
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    89
  for (NetDeviceContainer::Iterator i = d.Begin (); i != d.End (); ++i)
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    90
    {
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    91
      Ptr<NetDevice> dev = *i;
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    92
      EnablePcap (filename, dev->GetNode ()->GetId (), dev->GetIfIndex ());
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
}
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    95
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    96
  void
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    97
EmuHelper::EnablePcap (std::string filename, NodeContainer n)
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    98
{
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    99
  NS_LOG_FUNCTION (filename << &n);
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   100
  NetDeviceContainer devs;
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   101
  for (NodeContainer::Iterator i = n.Begin (); i != n.End (); ++i)
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   102
    {
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   103
      Ptr<Node> node = *i;
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   104
      for (uint32_t j = 0; j < node->GetNDevices (); ++j)
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   105
	{
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   106
	  devs.Add (node->GetDevice (j));
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   107
	}
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   108
    }
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   109
  EnablePcap (filename, devs);
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   110
}
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   111
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   112
  void
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   113
EmuHelper::EnablePcapAll (std::string filename)
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   114
{
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   115
  NS_LOG_FUNCTION (filename);
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   116
  EnablePcap (filename, NodeContainer::GetGlobal ());
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   117
}
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   118
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   119
  void 
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   120
EmuHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid)
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   121
{
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   122
  NS_LOG_FUNCTION (&os << nodeid << deviceid);
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   123
  Packet::EnablePrinting ();
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   124
  std::ostringstream oss;
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   125
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4147
diff changeset
   126
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::EmuNetDevice/MacRx";
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4147
diff changeset
   127
  Config::Connect (oss.str (), MakeBoundCallback (&EmuHelper::AsciiRxEvent, &os));
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   128
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   129
  oss.str ("");
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4147
diff changeset
   130
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::EmuNetDevice/TxQueue/Enqueue";
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4147
diff changeset
   131
  Config::Connect (oss.str (), MakeBoundCallback (&EmuHelper::AsciiEnqueueEvent, &os));
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   132
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   133
  oss.str ("");
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4147
diff changeset
   134
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::EmuNetDevice/TxQueue/Dequeue";
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4147
diff changeset
   135
  Config::Connect (oss.str (), MakeBoundCallback (&EmuHelper::AsciiDequeueEvent, &os));
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   136
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   137
  oss.str ("");
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4147
diff changeset
   138
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::EmuNetDevice/TxQueue/Drop";
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4147
diff changeset
   139
  Config::Connect (oss.str (), MakeBoundCallback (&EmuHelper::AsciiDropEvent, &os));
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   140
}
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   141
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   142
  void 
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   143
EmuHelper::EnableAscii (std::ostream &os, NetDeviceContainer d)
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   144
{
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   145
  NS_LOG_FUNCTION (&os << &d);
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   146
  for (NetDeviceContainer::Iterator i = d.Begin (); i != d.End (); ++i)
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   147
    {
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   148
      Ptr<NetDevice> dev = *i;
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   149
      EnableAscii (os, dev->GetNode ()->GetId (), dev->GetIfIndex ());
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   150
    }
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   151
}
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   152
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   153
void
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   154
EmuHelper::EnableAscii (std::ostream &os, NodeContainer n)
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   155
{
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   156
  NS_LOG_FUNCTION (&os << &n);
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   157
  NetDeviceContainer devs;
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   158
  for (NodeContainer::Iterator i = n.Begin (); i != n.End (); ++i)
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   159
    {
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   160
      Ptr<Node> node = *i;
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   161
      for (uint32_t j = 0; j < node->GetNDevices (); ++j)
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   162
	{
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   163
	  devs.Add (node->GetDevice (j));
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   164
	}
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   165
    }
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   166
  EnableAscii (os, devs);
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   167
}
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
  void
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   170
EmuHelper::EnableAsciiAll (std::ostream &os)
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   171
{
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   172
  NS_LOG_FUNCTION (&os);
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   173
  EnableAscii (os, NodeContainer::GetGlobal ());
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   174
}
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   175
3848
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   176
NetDeviceContainer
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   177
EmuHelper::Install (Ptr<Node> node) const
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   178
{
3848
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   179
  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
   180
}
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   181
4140
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
   182
NetDeviceContainer
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
   183
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
   184
{
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
   185
  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
   186
  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
   187
}
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
   188
3848
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   189
NetDeviceContainer 
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   190
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
   191
{
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   192
  NetDeviceContainer devs;
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   193
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   194
  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); i++)
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   195
    {
3848
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   196
      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
   197
    }
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   198
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   199
  return devs;
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   200
}
3828
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
  Ptr<NetDevice>
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   203
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
   204
{
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   205
  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
   206
  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
   207
  node->AddDevice (device);
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   208
  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
   209
  device->SetQueue (queue);
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   210
3848
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3837
diff changeset
   211
  return device;
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   212
}
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   213
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   214
  void 
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4147
diff changeset
   215
EmuHelper::SniffEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet)
3828
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   216
{
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   217
  NS_LOG_FUNCTION (writer << packet);
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   218
  writer->WritePacket (packet);
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
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   221
  void 
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   222
EmuHelper::AsciiEnqueueEvent (
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   223
  std::ostream *os, 
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   224
  std::string path, 
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   225
  Ptr<const Packet> packet)
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   226
{
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   227
  NS_LOG_FUNCTION (&os << path << packet);
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   228
  *os << "+ " << Simulator::Now ().GetSeconds () << " ";
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   229
  *os << path << " " << *packet << std::endl;
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   230
}
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   231
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   232
  void 
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   233
EmuHelper::AsciiDequeueEvent (
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   234
  std::ostream *os, 
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   235
  std::string path, 
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   236
  Ptr<const Packet> packet)
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   237
{
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   238
  NS_LOG_FUNCTION (&os << path << packet);
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   239
  *os << "- " << Simulator::Now ().GetSeconds () << " ";
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   240
  *os << path << " " << *packet << std::endl;
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   241
}
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   242
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   243
  void 
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   244
EmuHelper::AsciiDropEvent (
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   245
  std::ostream *os, 
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   246
  std::string path, 
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   247
  Ptr<const Packet> packet)
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   248
{
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   249
  NS_LOG_FUNCTION (&os << path << packet);
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   250
  *os << "d " << Simulator::Now ().GetSeconds () << " ";
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   251
  *os << path << " " << *packet << std::endl;
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   252
}
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   253
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   254
  void 
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   255
EmuHelper::AsciiRxEvent (
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   256
  std::ostream *os, 
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   257
  std::string path, 
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   258
  Ptr<const Packet> packet)
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   259
{
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   260
  NS_LOG_FUNCTION (&os << path << packet);
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   261
  *os << "r " << Simulator::Now ().GetSeconds () << " ";
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   262
  *os << path << " " << *packet << std::endl;
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   263
}
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   264
337b244e6d8f add in the helpers
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   265
} // namespace ns3