src/helper/point-to-point-helper.cc
author Craig Dowell <craigdo@ee.washington.edu>
Tue, 10 Mar 2009 23:47:55 -0700
changeset 4264 9d2e96c4e6e4
parent 4263 fec2f830d015
child 4448 641b88d1e131
permissions -rw-r--r--
Piles of changes for tracing rework
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2833
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2802
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2802
diff changeset
     2
/*
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2802
diff changeset
     3
 * Copyright (c) 2008 INRIA
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2802
diff changeset
     4
 *
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2802
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2802
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2802
diff changeset
     7
 * published by the Free Software Foundation;
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2802
diff changeset
     8
 *
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2802
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2802
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2802
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2802
diff changeset
    12
 * GNU General Public License for more details.
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2802
diff changeset
    13
 *
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2802
diff changeset
    14
 * You should have received a copy of the GNU General Public License
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2802
diff changeset
    15
 * along with this program; if not, write to the Free Software
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2802
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2802
diff changeset
    17
 *
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2802
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2802
diff changeset
    19
 */
2418
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
#include "point-to-point-helper.h"
2802
6beac0ec2c5d Prepend ascii trace lines with action and time
Tom Henderson <tomh@tomh.org>
parents: 2789
diff changeset
    21
#include "ns3/simulator.h"
2603
1308da4cb3bf move helpers to their own dir.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2433
diff changeset
    22
#include "ns3/point-to-point-net-device.h"
1308da4cb3bf move helpers to their own dir.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2433
diff changeset
    23
#include "ns3/point-to-point-channel.h"
2418
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
#include "ns3/queue.h"
2786
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
    25
#include "ns3/pcap-writer.h"
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
    26
#include "ns3/config.h"
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
    27
#include "ns3/packet.h"
4147
5d8530130930 rename object-names.{cc,h} to names.{cc,h} per convention
Craig Dowell <craigdo@ee.washington.edu>
parents: 4140
diff changeset
    28
#include "ns3/names.h"
2418
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    29
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
namespace ns3 {
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    31
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
PointToPointHelper::PointToPointHelper ()
2744
0ac8ce51ffba initialize factories correctly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2656
diff changeset
    34
{
0ac8ce51ffba initialize factories correctly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2656
diff changeset
    35
  m_queueFactory.SetTypeId ("ns3::DropTailQueue");
0ac8ce51ffba initialize factories correctly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2656
diff changeset
    36
  m_deviceFactory.SetTypeId ("ns3::PointToPointNetDevice");
0ac8ce51ffba initialize factories correctly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2656
diff changeset
    37
  m_channelFactory.SetTypeId ("ns3::PointToPointChannel");
0ac8ce51ffba initialize factories correctly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2656
diff changeset
    38
}
2418
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    39
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    40
void 
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    41
PointToPointHelper::SetQueue (std::string type,
3786
9f384deadb46 replace \t with 8 spaces.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3553
diff changeset
    42
                              std::string n1, const AttributeValue &v1,
9f384deadb46 replace \t with 8 spaces.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3553
diff changeset
    43
                              std::string n2, const AttributeValue &v2,
9f384deadb46 replace \t with 8 spaces.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3553
diff changeset
    44
                              std::string n3, const AttributeValue &v3,
9f384deadb46 replace \t with 8 spaces.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3553
diff changeset
    45
                              std::string n4, const AttributeValue &v4)
2418
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    46
{
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    47
  m_queueFactory.SetTypeId (type);
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    48
  m_queueFactory.Set (n1, v1);
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    49
  m_queueFactory.Set (n2, v2);
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    50
  m_queueFactory.Set (n3, v3);
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    51
  m_queueFactory.Set (n4, v4);
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    52
}
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    53
2603
1308da4cb3bf move helpers to their own dir.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2433
diff changeset
    54
void 
3381
3cdd9d60f7c7 bug 232, references to Parameter obsolete
Craig Dowell <craigdo@ee.washington.edu>
parents: 3012
diff changeset
    55
PointToPointHelper::SetDeviceAttribute (std::string n1, const AttributeValue &v1)
2603
1308da4cb3bf move helpers to their own dir.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2433
diff changeset
    56
{
1308da4cb3bf move helpers to their own dir.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2433
diff changeset
    57
  m_deviceFactory.Set (n1, v1);
1308da4cb3bf move helpers to their own dir.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2433
diff changeset
    58
}
1308da4cb3bf move helpers to their own dir.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2433
diff changeset
    59
1308da4cb3bf move helpers to their own dir.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2433
diff changeset
    60
void 
3381
3cdd9d60f7c7 bug 232, references to Parameter obsolete
Craig Dowell <craigdo@ee.washington.edu>
parents: 3012
diff changeset
    61
PointToPointHelper::SetChannelAttribute (std::string n1, const AttributeValue &v1)
2603
1308da4cb3bf move helpers to their own dir.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2433
diff changeset
    62
{
1308da4cb3bf move helpers to their own dir.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2433
diff changeset
    63
  m_channelFactory.Set (n1, v1);
1308da4cb3bf move helpers to their own dir.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2433
diff changeset
    64
}
1308da4cb3bf move helpers to their own dir.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2433
diff changeset
    65
2786
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
    66
void 
3403
ac82ff1f6736 use NS_DEPRECATED for bug 232.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3381
diff changeset
    67
PointToPointHelper::SetDeviceParameter (std::string name, const AttributeValue &value)
ac82ff1f6736 use NS_DEPRECATED for bug 232.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3381
diff changeset
    68
{
ac82ff1f6736 use NS_DEPRECATED for bug 232.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3381
diff changeset
    69
  SetDeviceAttribute (name, value);
ac82ff1f6736 use NS_DEPRECATED for bug 232.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3381
diff changeset
    70
}
ac82ff1f6736 use NS_DEPRECATED for bug 232.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3381
diff changeset
    71
void 
ac82ff1f6736 use NS_DEPRECATED for bug 232.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3381
diff changeset
    72
PointToPointHelper::SetChannelParameter (std::string name, const AttributeValue &value)
ac82ff1f6736 use NS_DEPRECATED for bug 232.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3381
diff changeset
    73
{
ac82ff1f6736 use NS_DEPRECATED for bug 232.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3381
diff changeset
    74
  SetChannelAttribute (name, value);
ac82ff1f6736 use NS_DEPRECATED for bug 232.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3381
diff changeset
    75
}
ac82ff1f6736 use NS_DEPRECATED for bug 232.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3381
diff changeset
    76
ac82ff1f6736 use NS_DEPRECATED for bug 232.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3381
diff changeset
    77
void 
2789
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
    78
PointToPointHelper::EnablePcap (std::string filename, uint32_t nodeid, uint32_t deviceid)
2786
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
    79
{
2789
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
    80
  std::ostringstream oss;
3789
616c83eeb4b9 bug 280: trace helpers too inclusive
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3786
diff changeset
    81
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::PointToPointNetDevice/";
616c83eeb4b9 bug 280: trace helpers too inclusive
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3786
diff changeset
    82
  Config::MatchContainer matches = Config::LookupMatches (oss.str ());
616c83eeb4b9 bug 280: trace helpers too inclusive
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3786
diff changeset
    83
  if (matches.GetN () == 0)
616c83eeb4b9 bug 280: trace helpers too inclusive
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3786
diff changeset
    84
    {
616c83eeb4b9 bug 280: trace helpers too inclusive
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3786
diff changeset
    85
      return;
616c83eeb4b9 bug 280: trace helpers too inclusive
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3786
diff changeset
    86
    }
616c83eeb4b9 bug 280: trace helpers too inclusive
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3786
diff changeset
    87
  oss.str ("");
2839
b30d4ece2bbb generate .pcap postfix for pcap filenames
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2834
diff changeset
    88
  oss << filename << "-" << nodeid << "-" << deviceid << ".pcap";
2789
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
    89
  Ptr<PcapWriter> pcap = Create<PcapWriter> ();
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
    90
  pcap->Open (oss.str ());
3012
56a4c75f9422 fix bug 161
Craig Dowell <craigdo@ee.washington.edu>
parents: 3010
diff changeset
    91
  pcap->WritePppHeader ();
2789
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
    92
  oss.str ("");
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
    93
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid;
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
    94
  oss << "/$ns3::PointToPointNetDevice/PromiscSniffer";
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4147
diff changeset
    95
  Config::ConnectWithoutContext (oss.str (), MakeBoundCallback (&PointToPointHelper::SniffEvent, pcap));
2786
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
    96
}
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
    97
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
    98
void 
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
    99
PointToPointHelper::EnablePcap (std::string filename, Ptr<NetDevice> nd)
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   100
{
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   101
  EnablePcap (filename, nd->GetNode ()->GetId (), nd->GetIfIndex ());
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   102
}
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   103
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   104
void 
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   105
PointToPointHelper::EnablePcap (std::string filename, std::string ndName)
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   106
{
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   107
  Ptr<NetDevice> nd = Names::Find<NetDevice> (ndName);
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   108
  EnablePcap (filename, nd->GetNode ()->GetId (), nd->GetIfIndex ());
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   109
}
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   110
2786
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
   111
void 
2789
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   112
PointToPointHelper::EnablePcap (std::string filename, NetDeviceContainer d)
2786
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
   113
{
2789
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   114
  for (NetDeviceContainer::Iterator i = d.Begin (); i != d.End (); ++i)
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   115
    {
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   116
      Ptr<NetDevice> dev = *i;
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   117
      EnablePcap (filename, dev->GetNode ()->GetId (), dev->GetIfIndex ());
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   118
    }
2786
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
   119
}
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   120
2789
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   121
void
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   122
PointToPointHelper::EnablePcap (std::string filename, NodeContainer n)
2786
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
   123
{
2789
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   124
  NetDeviceContainer devs;
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   125
  for (NodeContainer::Iterator i = n.Begin (); i != n.End (); ++i)
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   126
    {
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   127
      Ptr<Node> node = *i;
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   128
      for (uint32_t j = 0; j < node->GetNDevices (); ++j)
3786
9f384deadb46 replace \t with 8 spaces.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3553
diff changeset
   129
        {
9f384deadb46 replace \t with 8 spaces.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3553
diff changeset
   130
          devs.Add (node->GetDevice (j));
9f384deadb46 replace \t with 8 spaces.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3553
diff changeset
   131
        }
2789
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   132
    }
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   133
  EnablePcap (filename, devs);
2786
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
   134
}
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
   135
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
   136
void
2996
a83b94e277d4 EnablePcap()->EnablePcapAll(); EnableAscii()->EnableAsciiAll()
Tom Henderson <tomh@tomh.org>
parents: 2887
diff changeset
   137
PointToPointHelper::EnablePcapAll (std::string filename)
2786
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
   138
{
2789
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   139
  EnablePcap (filename, NodeContainer::GetGlobal ());
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   140
}
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   141
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   142
void 
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   143
PointToPointHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid)
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   144
{
3553
065488d0420c bug 279: Packets need metadata support for printing without header checking
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3403
diff changeset
   145
  Packet::EnablePrinting ();
2786
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
   146
  std::ostringstream oss;
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4147
diff changeset
   147
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::PointToPointNetDevice/MacRx";
2802
6beac0ec2c5d Prepend ascii trace lines with action and time
Tom Henderson <tomh@tomh.org>
parents: 2789
diff changeset
   148
  Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiRxEvent, &os));
2789
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   149
  oss.str ("");
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   150
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::PointToPointNetDevice/TxQueue/Enqueue";
2802
6beac0ec2c5d Prepend ascii trace lines with action and time
Tom Henderson <tomh@tomh.org>
parents: 2789
diff changeset
   151
  Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiEnqueueEvent, &os));
2789
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   152
  oss.str ("");
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   153
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::PointToPointNetDevice/TxQueue/Dequeue";
2802
6beac0ec2c5d Prepend ascii trace lines with action and time
Tom Henderson <tomh@tomh.org>
parents: 2789
diff changeset
   154
  Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiDequeueEvent, &os));
6beac0ec2c5d Prepend ascii trace lines with action and time
Tom Henderson <tomh@tomh.org>
parents: 2789
diff changeset
   155
  oss.str ("");
6beac0ec2c5d Prepend ascii trace lines with action and time
Tom Henderson <tomh@tomh.org>
parents: 2789
diff changeset
   156
  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::PointToPointNetDevice/TxQueue/Drop";
6beac0ec2c5d Prepend ascii trace lines with action and time
Tom Henderson <tomh@tomh.org>
parents: 2789
diff changeset
   157
  Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiDropEvent, &os));
2789
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   158
}
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   159
2789
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   160
void 
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   161
PointToPointHelper::EnableAscii (std::ostream &os, NetDeviceContainer d)
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   162
{
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   163
  for (NetDeviceContainer::Iterator i = d.Begin (); i != d.End (); ++i)
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   164
    {
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   165
      Ptr<NetDevice> dev = *i;
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   166
      EnableAscii (os, dev->GetNode ()->GetId (), dev->GetIfIndex ());
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   167
    }
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   168
}
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   169
2789
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   170
void
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   171
PointToPointHelper::EnableAscii (std::ostream &os, NodeContainer n)
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   172
{
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   173
  NetDeviceContainer devs;
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   174
  for (NodeContainer::Iterator i = n.Begin (); i != n.End (); ++i)
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   175
    {
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   176
      Ptr<Node> node = *i;
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   177
      for (uint32_t j = 0; j < node->GetNDevices (); ++j)
3786
9f384deadb46 replace \t with 8 spaces.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3553
diff changeset
   178
        {
9f384deadb46 replace \t with 8 spaces.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3553
diff changeset
   179
          devs.Add (node->GetDevice (j));
9f384deadb46 replace \t with 8 spaces.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3553
diff changeset
   180
        }
2789
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   181
    }
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   182
  EnableAscii (os, devs);
2786
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
   183
}
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
   184
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
   185
void
2996
a83b94e277d4 EnablePcap()->EnablePcapAll(); EnableAscii()->EnableAsciiAll()
Tom Henderson <tomh@tomh.org>
parents: 2887
diff changeset
   186
PointToPointHelper::EnableAsciiAll (std::ostream &os)
2786
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
   187
{
2789
47e92324cf4b configure tracing post-topology construction, not before.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2786
diff changeset
   188
  EnableAscii (os, NodeContainer::GetGlobal ());
2786
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
   189
}
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
   190
2418
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   191
NetDeviceContainer 
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2839
diff changeset
   192
PointToPointHelper::Install (NodeContainer c)
2418
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   193
{
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   194
  NS_ASSERT (c.GetN () == 2);
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2839
diff changeset
   195
  return Install (c.Get (0), c.Get (1));
2418
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   196
}
3793
a5895f134543 make star topologies easier to create
Craig Dowell <craigdo@ee.washington.edu>
parents: 3553
diff changeset
   197
2418
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   198
NetDeviceContainer 
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2839
diff changeset
   199
PointToPointHelper::Install (Ptr<Node> a, Ptr<Node> b)
2418
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   200
{
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   201
  NetDeviceContainer container;
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   202
2745
58eba4bfcc4a use the factories.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2744
diff changeset
   203
  Ptr<PointToPointNetDevice> devA = m_deviceFactory.Create<PointToPointNetDevice> ();
2656
b426a0e0355e call SetAddress during construction to assign MAC-level addresses.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2603
diff changeset
   204
  devA->SetAddress (Mac48Address::Allocate ());
2603
1308da4cb3bf move helpers to their own dir.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2433
diff changeset
   205
  a->AddDevice (devA);
1308da4cb3bf move helpers to their own dir.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2433
diff changeset
   206
  Ptr<Queue> queueA = m_queueFactory.Create<Queue> ();
3010
ad669f4f7e58 bug 153
Craig Dowell <craigdo@ee.washington.edu>
parents: 2997
diff changeset
   207
  devA->SetQueue (queueA);
2745
58eba4bfcc4a use the factories.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2744
diff changeset
   208
  Ptr<PointToPointNetDevice> devB = m_deviceFactory.Create<PointToPointNetDevice> ();
2656
b426a0e0355e call SetAddress during construction to assign MAC-level addresses.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2603
diff changeset
   209
  devB->SetAddress (Mac48Address::Allocate ());
2603
1308da4cb3bf move helpers to their own dir.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2433
diff changeset
   210
  b->AddDevice (devB);
1308da4cb3bf move helpers to their own dir.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2433
diff changeset
   211
  Ptr<Queue> queueB = m_queueFactory.Create<Queue> ();
3010
ad669f4f7e58 bug 153
Craig Dowell <craigdo@ee.washington.edu>
parents: 2997
diff changeset
   212
  devB->SetQueue (queueB);
2745
58eba4bfcc4a use the factories.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2744
diff changeset
   213
  Ptr<PointToPointChannel> channel = m_channelFactory.Create<PointToPointChannel> ();
2418
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   214
  devA->Attach (channel);
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   215
  devB->Attach (channel);
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   216
  container.Add (devA);
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   217
  container.Add (devB);
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   218
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   219
  return container;
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   220
}
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   221
4140
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   222
NetDeviceContainer 
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   223
PointToPointHelper::Install (Ptr<Node> a, std::string bName)
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   224
{
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   225
  Ptr<Node> b = Names::Find<Node> (bName);
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   226
  return Install (a, b);
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   227
}
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   228
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   229
NetDeviceContainer 
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   230
PointToPointHelper::Install (std::string aName, Ptr<Node> b)
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   231
{
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   232
  Ptr<Node> a = Names::Find<Node> (aName);
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   233
  return Install (a, b);
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   234
}
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   235
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   236
NetDeviceContainer 
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   237
PointToPointHelper::Install (std::string aName, std::string bName)
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   238
{
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   239
  Ptr<Node> a = Names::Find<Node> (aName);
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   240
  Ptr<Node> b = Names::Find<Node> (bName);
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   241
  return Install (a, b);
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   242
}
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   243
2786
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
   244
void 
3793
a5895f134543 make star topologies easier to create
Craig Dowell <craigdo@ee.washington.edu>
parents: 3553
diff changeset
   245
PointToPointHelper::InstallStar (Ptr<Node> hub, NodeContainer spokes, 
a5895f134543 make star topologies easier to create
Craig Dowell <craigdo@ee.washington.edu>
parents: 3553
diff changeset
   246
                                 NetDeviceContainer& hubDevices, NetDeviceContainer& spokeDevices)
a5895f134543 make star topologies easier to create
Craig Dowell <craigdo@ee.washington.edu>
parents: 3553
diff changeset
   247
{
a5895f134543 make star topologies easier to create
Craig Dowell <craigdo@ee.washington.edu>
parents: 3553
diff changeset
   248
  for (uint32_t i = 0; i < spokes.GetN (); ++i)
a5895f134543 make star topologies easier to create
Craig Dowell <craigdo@ee.washington.edu>
parents: 3553
diff changeset
   249
    {
a5895f134543 make star topologies easier to create
Craig Dowell <craigdo@ee.washington.edu>
parents: 3553
diff changeset
   250
      NetDeviceContainer nd = Install (hub, spokes.Get (i));
a5895f134543 make star topologies easier to create
Craig Dowell <craigdo@ee.washington.edu>
parents: 3553
diff changeset
   251
      hubDevices.Add (nd.Get (0));
a5895f134543 make star topologies easier to create
Craig Dowell <craigdo@ee.washington.edu>
parents: 3553
diff changeset
   252
      spokeDevices.Add (nd.Get (1));
a5895f134543 make star topologies easier to create
Craig Dowell <craigdo@ee.washington.edu>
parents: 3553
diff changeset
   253
    }
a5895f134543 make star topologies easier to create
Craig Dowell <craigdo@ee.washington.edu>
parents: 3553
diff changeset
   254
}
a5895f134543 make star topologies easier to create
Craig Dowell <craigdo@ee.washington.edu>
parents: 3553
diff changeset
   255
a5895f134543 make star topologies easier to create
Craig Dowell <craigdo@ee.washington.edu>
parents: 3553
diff changeset
   256
void 
4140
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   257
PointToPointHelper::InstallStar (std::string hubName, NodeContainer spokes, 
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   258
                                 NetDeviceContainer& hubDevices, NetDeviceContainer& spokeDevices)
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   259
{
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   260
  Ptr<Node> hub = Names::Find<Node> (hubName);
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   261
  InstallStar (hub, spokes, hubDevices, spokeDevices);
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   262
}
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   263
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3794
diff changeset
   264
void 
4263
fec2f830d015 trace consistency changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 4147
diff changeset
   265
PointToPointHelper::SniffEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet)
2786
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
   266
{
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
   267
  writer->WritePacket (packet);
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
   268
}
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   269
2786
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
   270
void 
2802
6beac0ec2c5d Prepend ascii trace lines with action and time
Tom Henderson <tomh@tomh.org>
parents: 2789
diff changeset
   271
PointToPointHelper::AsciiEnqueueEvent (std::ostream *os, std::string path, Ptr<const Packet> packet)
6beac0ec2c5d Prepend ascii trace lines with action and time
Tom Henderson <tomh@tomh.org>
parents: 2789
diff changeset
   272
{
6beac0ec2c5d Prepend ascii trace lines with action and time
Tom Henderson <tomh@tomh.org>
parents: 2789
diff changeset
   273
  *os << "+ " << Simulator::Now ().GetSeconds () << " ";
6beac0ec2c5d Prepend ascii trace lines with action and time
Tom Henderson <tomh@tomh.org>
parents: 2789
diff changeset
   274
  *os << path << " " << *packet << std::endl;
6beac0ec2c5d Prepend ascii trace lines with action and time
Tom Henderson <tomh@tomh.org>
parents: 2789
diff changeset
   275
}
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   276
2802
6beac0ec2c5d Prepend ascii trace lines with action and time
Tom Henderson <tomh@tomh.org>
parents: 2789
diff changeset
   277
void 
6beac0ec2c5d Prepend ascii trace lines with action and time
Tom Henderson <tomh@tomh.org>
parents: 2789
diff changeset
   278
PointToPointHelper::AsciiDequeueEvent (std::ostream *os, std::string path, Ptr<const Packet> packet)
2786
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
   279
{
2802
6beac0ec2c5d Prepend ascii trace lines with action and time
Tom Henderson <tomh@tomh.org>
parents: 2789
diff changeset
   280
  *os << "- " << Simulator::Now ().GetSeconds () << " ";
6beac0ec2c5d Prepend ascii trace lines with action and time
Tom Henderson <tomh@tomh.org>
parents: 2789
diff changeset
   281
  *os << path << " " << *packet << std::endl;
6beac0ec2c5d Prepend ascii trace lines with action and time
Tom Henderson <tomh@tomh.org>
parents: 2789
diff changeset
   282
}
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   283
2802
6beac0ec2c5d Prepend ascii trace lines with action and time
Tom Henderson <tomh@tomh.org>
parents: 2789
diff changeset
   284
void 
6beac0ec2c5d Prepend ascii trace lines with action and time
Tom Henderson <tomh@tomh.org>
parents: 2789
diff changeset
   285
PointToPointHelper::AsciiDropEvent (std::ostream *os, std::string path, Ptr<const Packet> packet)
6beac0ec2c5d Prepend ascii trace lines with action and time
Tom Henderson <tomh@tomh.org>
parents: 2789
diff changeset
   286
{
6beac0ec2c5d Prepend ascii trace lines with action and time
Tom Henderson <tomh@tomh.org>
parents: 2789
diff changeset
   287
  *os << "d " << Simulator::Now ().GetSeconds () << " ";
6beac0ec2c5d Prepend ascii trace lines with action and time
Tom Henderson <tomh@tomh.org>
parents: 2789
diff changeset
   288
  *os << path << " " << *packet << std::endl;
6beac0ec2c5d Prepend ascii trace lines with action and time
Tom Henderson <tomh@tomh.org>
parents: 2789
diff changeset
   289
}
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4263
diff changeset
   290
2802
6beac0ec2c5d Prepend ascii trace lines with action and time
Tom Henderson <tomh@tomh.org>
parents: 2789
diff changeset
   291
void 
6beac0ec2c5d Prepend ascii trace lines with action and time
Tom Henderson <tomh@tomh.org>
parents: 2789
diff changeset
   292
PointToPointHelper::AsciiRxEvent (std::ostream *os, std::string path, Ptr<const Packet> packet)
6beac0ec2c5d Prepend ascii trace lines with action and time
Tom Henderson <tomh@tomh.org>
parents: 2789
diff changeset
   293
{
6beac0ec2c5d Prepend ascii trace lines with action and time
Tom Henderson <tomh@tomh.org>
parents: 2789
diff changeset
   294
  *os << "r " << Simulator::Now ().GetSeconds () << " ";
2786
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
   295
  *os << path << " " << *packet << std::endl;
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
   296
}
f261e50396ac add ascii/pcap trace helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2745
diff changeset
   297
2418
4ff45fa08781 an initial draft of helper classes. don't work yet.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   298
} // namespace ns3