examples/simple-point-to-point-olsr.cc
author Tom Henderson <tomh@tomh.org>
Sat, 17 May 2008 12:08:20 -0700
changeset 3125 d2d8a36cfd23
parent 2997 caf9d364c6fc
child 3127 f5971b43ee58
permissions -rw-r--r--
s/ns3::Udp/ns3::UdpSocketFactory
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     2
/*
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     3
 * This program is free software; you can redistribute it and/or modify
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     4
 * it under the terms of the GNU General Public License version 2 as
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     5
 * published by the Free Software Foundation;
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     6
 *
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     7
 * This program is distributed in the hope that it will be useful,
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    10
 * GNU General Public License for more details.
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    11
 *
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    12
 * You should have received a copy of the GNU General Public License
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    13
 * along with this program; if not, write to the Free Software
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    15
 *
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    16
 * ns-2 simple.tcl script (ported from ns-2)
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    17
 * Originally authored by Steve McCanne, 12/19/1996
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    18
 */
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    19
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    20
// Port of ns-2/tcl/ex/simple.tcl to ns-3
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    21
//
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    22
// Network topology
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    23
//
2295
39452dbe604b Fix OLSR example: don't add static routes, increase simulation time to 300 seconds.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2257
diff changeset
    24
//   n0
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    25
//     \ 5 Mb/s, 2ms
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    26
//      \          1.5Mb/s, 10ms
2327
6496b4d93372 Make the OLSR example a bit more complete, adding a 5th node, to exercise 3-hop routing.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2298
diff changeset
    27
//       n2 -------------------------n3---------n4
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    28
//      /
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    29
//     / 5 Mb/s, 2ms
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    30
//   n1
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    31
//
988
89a9125a39c9 rename example from p2p to point-to-point
Tom Henderson <tomh@tomh.org>
parents: 973
diff changeset
    32
// - all links are point-to-point links with indicated one-way BW/delay
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    33
// - CBR/UDP flows from n0 to n3, and from n3 to n1
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    34
// - FTP/TCP flow from n0 to n3, starting at time 1.2 to time 1.35 sec.
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    35
// - UDP packet size of 210 bytes, with per-packet interval 0.00375 sec.
382
26528ff50d38 Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents: 381
diff changeset
    36
//   (i.e., DataRate of 448,000 bps)
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    37
// - DropTail queues 
2821
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    38
// - Tracing of queues and packet receptions to file "simple-point-to-point-olsr.tr"
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    39
2821
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    40
#include <iostream>
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    41
#include <fstream>
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    42
#include <string>
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    43
#include <cassert>
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    44
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    45
#include "ns3/core-module.h"
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    46
#include "ns3/simulator-module.h"
2890
172baa5960ff rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents: 2889
diff changeset
    47
#include "ns3/node-module.h"
2821
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    48
#include "ns3/helper-module.h"
1742
cf76416ce75b merge with ns-3-dev
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1421
diff changeset
    49
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    50
using namespace ns3;
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    51
2821
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    52
NS_LOG_COMPONENT_DEFINE ("SimpleGlobalRoutingExample");
1748
d2b5acae027d Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1745
diff changeset
    53
d2b5acae027d Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1745
diff changeset
    54
int 
d2b5acae027d Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1745
diff changeset
    55
main (int argc, char *argv[])
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    56
{
534
9fa0b6f245d7 Cosmetic: change strings in the bind commands for queue. Move Bind() before CommandLine::Parse() in example script
Tom Henderson <tomh@tomh.org>
parents: 523
diff changeset
    57
  // Users may find it convenient to turn on explicit debugging
9fa0b6f245d7 Cosmetic: change strings in the bind commands for queue. Move Bind() before CommandLine::Parse() in example script
Tom Henderson <tomh@tomh.org>
parents: 523
diff changeset
    58
  // for selected modules; the below lines suggest how to do this
535
fb6735f93868 Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents: 534
diff changeset
    59
#if 0 
2821
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    60
  LogComponentEnable ("SimpleGlobalRoutingExample", LOG_LEVEL_INFO);
2860
9105a5cf6535 use global seed in examples, new regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 2838
diff changeset
    61
#endif
1748
d2b5acae027d Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1745
diff changeset
    62
2860
9105a5cf6535 use global seed in examples, new regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 2838
diff changeset
    63
  //
9105a5cf6535 use global seed in examples, new regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 2838
diff changeset
    64
  // Make the random number generators generate reproducible results.
9105a5cf6535 use global seed in examples, new regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 2838
diff changeset
    65
  //
9105a5cf6535 use global seed in examples, new regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 2838
diff changeset
    66
  RandomVariable::UseGlobalSeed (1, 1, 2, 3, 5, 8);
9105a5cf6535 use global seed in examples, new regression tests
Craig Dowell <craigdo@ee.washington.edu>
parents: 2838
diff changeset
    67
2821
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    68
  // Set up some default values for the simulation.  Use the 
534
9fa0b6f245d7 Cosmetic: change strings in the bind commands for queue. Move Bind() before CommandLine::Parse() in example script
Tom Henderson <tomh@tomh.org>
parents: 523
diff changeset
    69
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2890
diff changeset
    70
  Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (210));
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2890
diff changeset
    71
  Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("448kb/s"));
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    72
1224
7cbc1d661b89 rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1204
diff changeset
    73
  //DefaultValue::Bind ("DropTailQueue::m_maxPackets", 30);   
534
9fa0b6f245d7 Cosmetic: change strings in the bind commands for queue. Move Bind() before CommandLine::Parse() in example script
Tom Henderson <tomh@tomh.org>
parents: 523
diff changeset
    74
9fa0b6f245d7 Cosmetic: change strings in the bind commands for queue. Move Bind() before CommandLine::Parse() in example script
Tom Henderson <tomh@tomh.org>
parents: 523
diff changeset
    75
  // Allow the user to override any of the defaults and the above
2821
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    76
  // DefaultValue::Bind ()s at run-time, via command-line arguments
2575
1aae382e65e2 rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    77
  CommandLine cmd;
1aae382e65e2 rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    78
  cmd.Parse (argc, argv);
534
9fa0b6f245d7 Cosmetic: change strings in the bind commands for queue. Move Bind() before CommandLine::Parse() in example script
Tom Henderson <tomh@tomh.org>
parents: 523
diff changeset
    79
9fa0b6f245d7 Cosmetic: change strings in the bind commands for queue. Move Bind() before CommandLine::Parse() in example script
Tom Henderson <tomh@tomh.org>
parents: 523
diff changeset
    80
  // Here, we will explicitly create four nodes.  In more sophisticated
9fa0b6f245d7 Cosmetic: change strings in the bind commands for queue. Move Bind() before CommandLine::Parse() in example script
Tom Henderson <tomh@tomh.org>
parents: 523
diff changeset
    81
  // topologies, we could configure a node factory.
1748
d2b5acae027d Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1745
diff changeset
    82
  NS_LOG_INFO ("Create nodes.");
2821
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    83
  NodeContainer c;
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    84
  c.Create (5);
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    85
  NodeContainer n02 = NodeContainer (c.Get(0), c.Get (2));
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    86
  NodeContainer n12 = NodeContainer (c.Get(1), c.Get (2));
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    87
  NodeContainer n32 = NodeContainer (c.Get(3), c.Get (2));
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    88
  NodeContainer n34 = NodeContainer (c.Get (3), c.Get (4));
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    89
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    90
  InternetStackHelper internet;
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2860
diff changeset
    91
  internet.Install (c);
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    92
534
9fa0b6f245d7 Cosmetic: change strings in the bind commands for queue. Move Bind() before CommandLine::Parse() in example script
Tom Henderson <tomh@tomh.org>
parents: 523
diff changeset
    93
  // We create the channels first without any IP addressing information
1748
d2b5acae027d Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1745
diff changeset
    94
  NS_LOG_INFO ("Create channels.");
2821
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    95
  PointToPointHelper p2p;
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2890
diff changeset
    96
  p2p.SetChannelParameter ("BitRate", StringValue ("5Mbps"));
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2890
diff changeset
    97
  p2p.SetChannelParameter ("Delay", StringValue ("2ms"));
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2860
diff changeset
    98
  NetDeviceContainer nd02 = p2p.Install (n02);
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2860
diff changeset
    99
  NetDeviceContainer nd12 = p2p.Install (n12);
2974
30ed185e0364 avoid crash due to mis-spelled data rate unit
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2965
diff changeset
   100
  p2p.SetChannelParameter ("BitRate", StringValue ("1500kbps"));
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2890
diff changeset
   101
  p2p.SetChannelParameter ("Delay", StringValue ("10ms"));
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2860
diff changeset
   102
  NetDeviceContainer nd32 = p2p.Install (n32);
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2860
diff changeset
   103
  NetDeviceContainer nd34 = p2p.Install (n34);
535
fb6735f93868 Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents: 534
diff changeset
   104
  
fb6735f93868 Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents: 534
diff changeset
   105
  // Later, we add IP addresses.  
1748
d2b5acae027d Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1745
diff changeset
   106
  NS_LOG_INFO ("Assign IP Addresses.");
2821
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   107
  Ipv4AddressHelper ipv4;
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   108
  ipv4.SetBase ("10.1.1.0", "255.255.255.0");
2888
872dc8466352 Ipv4AddressHelper::Allocate -> Ipv4AddressHelper::Assign
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2887
diff changeset
   109
  Ipv4InterfaceContainer i02 = ipv4.Assign (nd02);
2821
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   110
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   111
  ipv4.SetBase ("10.1.2.0", "255.255.255.0");
2888
872dc8466352 Ipv4AddressHelper::Allocate -> Ipv4AddressHelper::Assign
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2887
diff changeset
   112
  Ipv4InterfaceContainer i12 = ipv4.Assign (nd12);
535
fb6735f93868 Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents: 534
diff changeset
   113
  
2821
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   114
  ipv4.SetBase ("10.1.3.0", "255.255.255.0");
2888
872dc8466352 Ipv4AddressHelper::Allocate -> Ipv4AddressHelper::Assign
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2887
diff changeset
   115
  Ipv4InterfaceContainer i32 = ipv4.Assign (nd32);
540
507eababb124 Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents: 535
diff changeset
   116
2821
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   117
  ipv4.SetBase ("10.1.4.0", "255.255.255.0");
2888
872dc8466352 Ipv4AddressHelper::Allocate -> Ipv4AddressHelper::Assign
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2887
diff changeset
   118
  Ipv4InterfaceContainer i34 = ipv4.Assign (nd34);
2295
39452dbe604b Fix OLSR example: don't add static routes, increase simulation time to 300 seconds.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2257
diff changeset
   119
39452dbe604b Fix OLSR example: don't add static routes, increase simulation time to 300 seconds.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2257
diff changeset
   120
  // Enable OLSR
1748
d2b5acae027d Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1745
diff changeset
   121
  NS_LOG_INFO ("Enabling OLSR Routing.");
2484
d5b05b706999 port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2298
diff changeset
   122
  OlsrHelper olsr;
2995
b72805b3ca69 Align helper API use of Install()
Tom Henderson <tomh@tomh.org>
parents: 2890
diff changeset
   123
  olsr.InstallAll ();
535
fb6735f93868 Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents: 534
diff changeset
   124
382
26528ff50d38 Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents: 381
diff changeset
   125
  // Create the OnOff application to send UDP datagrams of size
26528ff50d38 Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents: 381
diff changeset
   126
  // 210 bytes at a rate of 448 Kb/s
1748
d2b5acae027d Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1745
diff changeset
   127
  NS_LOG_INFO ("Create Applications.");
d2b5acae027d Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1745
diff changeset
   128
  uint16_t port = 9;   // Discard port (RFC 863)
2890
172baa5960ff rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents: 2889
diff changeset
   129
3125
d2d8a36cfd23 s/ns3::Udp/ns3::UdpSocketFactory
Tom Henderson <tomh@tomh.org>
parents: 2997
diff changeset
   130
  OnOffHelper onoff ("ns3::UdpSocketFactory", 
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2890
diff changeset
   131
                     InetSocketAddress (i34.GetAddress (1), port));
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2890
diff changeset
   132
  onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2890
diff changeset
   133
  onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
2890
172baa5960ff rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents: 2889
diff changeset
   134
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2860
diff changeset
   135
  ApplicationContainer apps = onoff.Install (c.Get (0));
2821
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   136
  apps.Start (Seconds (1.0));
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   137
  apps.Stop (Seconds (10.0));
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   138
2821
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   139
  // Create a packet sink to receive these packets
3125
d2d8a36cfd23 s/ns3::Udp/ns3::UdpSocketFactory
Tom Henderson <tomh@tomh.org>
parents: 2997
diff changeset
   140
  PacketSinkHelper sink ("ns3::UdpSocketFactory",
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2890
diff changeset
   141
                         InetSocketAddress (Ipv4Address::GetAny (), port));
2890
172baa5960ff rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents: 2889
diff changeset
   142
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2860
diff changeset
   143
  apps = sink.Install (c.Get (3));
2821
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   144
  apps.Start (Seconds (1.0));
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   145
  apps.Stop (Seconds (10.0));
1320
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1290
diff changeset
   146
382
26528ff50d38 Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents: 381
diff changeset
   147
  // Create a similar flow from n3 to n1, starting at time 1.1 seconds
2890
172baa5960ff rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents: 2889
diff changeset
   148
  onoff.SetAttribute ("Remote",
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2890
diff changeset
   149
                      AddressValue (InetSocketAddress (i12.GetAddress (0), port)));
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2860
diff changeset
   150
  apps = onoff.Install (c.Get (3));
2821
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   151
  apps.Start (Seconds (1.1));
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   152
  apps.Stop (Seconds (10.0));
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   153
1320
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1290
diff changeset
   154
  // Create a packet sink to receive these packets
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2860
diff changeset
   155
  apps = sink.Install (c.Get (1));
2821
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   156
  apps.Start (Seconds (1.1));
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   157
  apps.Stop (Seconds (10.0));
1320
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1290
diff changeset
   158
2821
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   159
  std::ofstream ascii;
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   160
  ascii.open ("simple-point-to-point-olsr.tr");
2996
a83b94e277d4 EnablePcap()->EnablePcapAll(); EnableAscii()->EnableAsciiAll()
Tom Henderson <tomh@tomh.org>
parents: 2995
diff changeset
   161
  PointToPointHelper::EnablePcapAll ("simple-point-to-point-olsr");
a83b94e277d4 EnablePcap()->EnablePcapAll(); EnableAscii()->EnableAsciiAll()
Tom Henderson <tomh@tomh.org>
parents: 2995
diff changeset
   162
  PointToPointHelper::EnableAsciiAll (ascii);
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   163
2823
a743c59882a0 add back max simulation time on olsr example
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2821
diff changeset
   164
  Simulator::StopAt (Seconds (30));
a743c59882a0 add back max simulation time on olsr example
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2821
diff changeset
   165
1748
d2b5acae027d Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1745
diff changeset
   166
  NS_LOG_INFO ("Run Simulation.");
2298
f61e41169911 Put back the simulation time in 30 seconds, else we generate huge trace files.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2295
diff changeset
   167
  Simulator::Run ();
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   168
  Simulator::Destroy ();
1748
d2b5acae027d Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1745
diff changeset
   169
  NS_LOG_INFO ("Done.");
2821
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   170
8e1f6f923c51 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   171
  return 0;
368
1df1165d6a68 Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   172
}