src/helper/packet-sink-helper.cc
author Craig Dowell <craigdo@ee.washington.edu>
Tue, 20 Jan 2009 17:39:18 -0800
changeset 4140 6bbf05bf4826
parent 3848 affd0834debc
child 4147 5d8530130930
permissions -rw-r--r--
Brute force all of the helpers to use object name service
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2833
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
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: 2731
diff changeset
     2
/*
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
diff changeset
     3
 * Copyright (c) 2008 INRIA
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
diff changeset
     4
 *
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
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: 2731
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: 2731
diff changeset
     7
 * published by the Free Software Foundation;
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
diff changeset
     8
 *
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
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: 2731
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: 2731
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: 2731
diff changeset
    12
 * GNU General Public License for more details.
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
diff changeset
    13
 *
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
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: 2731
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: 2731
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: 2731
diff changeset
    17
 *
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
diff changeset
    19
 */
3848
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3132
diff changeset
    20
2731
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
#include "packet-sink-helper.h"
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
#include "ns3/string.h"
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
#include "ns3/inet-socket-address.h"
4140
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
    24
#include "ns3/object-names.h"
2731
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    25
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
namespace ns3 {
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
2890
172baa5960ff rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents: 2889
diff changeset
    28
PacketSinkHelper::PacketSinkHelper (std::string protocol, Address address)
2731
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    29
{
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
  m_factory.SetTypeId ("ns3::PacketSink");
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2890
diff changeset
    31
  m_factory.Set ("Protocol", StringValue (protocol));
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2890
diff changeset
    32
  m_factory.Set ("Local", AddressValue (address));
2731
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
}
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    35
void 
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2890
diff changeset
    36
PacketSinkHelper::SetAttribute (std::string name, const AttributeValue &value)
2890
172baa5960ff rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents: 2889
diff changeset
    37
{
172baa5960ff rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents: 2889
diff changeset
    38
  m_factory.Set (name, value);
172baa5960ff rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents: 2889
diff changeset
    39
}
172baa5960ff rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents: 2889
diff changeset
    40
172baa5960ff rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents: 2889
diff changeset
    41
172baa5960ff rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents: 2889
diff changeset
    42
#if 0
172baa5960ff rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents: 2889
diff changeset
    43
void 
2889
969d4f6ab9ba SetupUdp -> SetUdpLocal, SetupTcp -> SetTcpLocal
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2887
diff changeset
    44
PacketSinkHelper::SetUdpLocal (Ipv4Address ip, uint16_t port)
2731
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    45
{
3125
d2d8a36cfd23 s/ns3::Udp/ns3::UdpSocketFactory
Tom Henderson <tomh@tomh.org>
parents: 2965
diff changeset
    46
  m_factory.Set ("Protocol", String ("ns3::UdpSocketFactory"));
2731
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    47
  m_factory.Set ("Local", Address (InetSocketAddress (ip, port)));
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    48
}
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    49
void 
2889
969d4f6ab9ba SetupUdp -> SetUdpLocal, SetupTcp -> SetTcpLocal
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2887
diff changeset
    50
PacketSinkHelper::SetTcpLocal (Ipv4Address ip, uint16_t port)
2731
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    51
{
3132
b0b0abb911cd move Tcp to TcpSocketFactory
Tom Henderson <tomh@tomh.org>
parents: 3125
diff changeset
    52
  m_factory.Set ("Protocol", String ("ns3::TcpSocketFactory"));
2731
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    53
  m_factory.Set ("Local", Address (InetSocketAddress (ip, port)));
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    54
}
2890
172baa5960ff rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents: 2889
diff changeset
    55
#endif
2731
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    56
3848
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3132
diff changeset
    57
ApplicationContainer
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3132
diff changeset
    58
PacketSinkHelper::Install (Ptr<Node> node) const
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3132
diff changeset
    59
{
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3132
diff changeset
    60
  return ApplicationContainer (InstallPriv (node));
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3132
diff changeset
    61
}
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3132
diff changeset
    62
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3132
diff changeset
    63
ApplicationContainer
4140
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
    64
PacketSinkHelper::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
    65
{
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
    66
  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
    67
  return ApplicationContainer (InstallPriv (node));
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
    68
}
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
    69
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
    70
ApplicationContainer
3848
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3132
diff changeset
    71
PacketSinkHelper::Install (NodeContainer c) const
2731
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    72
{
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    73
  ApplicationContainer apps;
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    74
  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    75
    {
3848
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3132
diff changeset
    76
      apps.Add (InstallPriv (*i));
2731
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    77
    }
3848
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3132
diff changeset
    78
2731
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    79
  return apps;
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    80
}
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    81
3848
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3132
diff changeset
    82
Ptr<Application>
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3132
diff changeset
    83
PacketSinkHelper::InstallPriv (Ptr<Node> node) const
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3132
diff changeset
    84
{
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3132
diff changeset
    85
  Ptr<Application> app = m_factory.Create<Application> ();
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3132
diff changeset
    86
  node->AddApplication (app);
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3132
diff changeset
    87
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3132
diff changeset
    88
  return app;
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 3132
diff changeset
    89
}
2731
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    90
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    91
} // namespace ns3