src/mesh/test/flame/flame-regression.cc
author Tommaso Pecorella <tommaso.pecorella@unifi.it>
Thu, 09 Jul 2015 23:52:12 +0200
changeset 11485 df37afec1b0f
parent 11015 a72b38546141
permissions -rw-r--r--
Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5826
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     2
/*
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     3
 * Copyright (c) 2009 IITP RAS
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     4
 *
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     8
 *
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    12
 * GNU General Public License for more details.
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    13
 *
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    17
 *
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    18
 * Authors: Kirill Andreev <andreev@iitp.ru>
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    19
 */
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    20
#include "ns3/mesh-helper.h"
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    21
#include "ns3/simulator.h"
8992
4fdf03b24af6 Update mesh model, tests and reference traces for new random variable usage
Tom Henderson <tomh@tomh.org>
parents: 7379
diff changeset
    22
#include "ns3/random-variable-stream.h"
4fdf03b24af6 Update mesh model, tests and reference traces for new random variable usage
Tom Henderson <tomh@tomh.org>
parents: 7379
diff changeset
    23
#include "ns3/rng-seed-manager.h"
5826
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    24
#include "ns3/mobility-helper.h"
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    25
#include "ns3/double.h"
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    26
#include "ns3/uinteger.h"
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    27
#include "ns3/string.h"
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    28
#include "ns3/yans-wifi-helper.h"
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    29
#include "ns3/internet-stack-helper.h"
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    30
#include "ns3/ipv4-address-helper.h"
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    31
#include "ns3/abort.h"
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7256
diff changeset
    32
#include "ns3/pcap-test.h"
5826
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    33
#include "ns3/mobility-model.h"
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    34
#include <sstream>
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    35
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    36
#include "flame-regression.h"
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    37
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    38
using namespace ns3;
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    39
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    40
/// Unique PCAP file name prefix
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    41
const char * const PREFIX = "flame-regression-test";
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    42
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    43
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    44
FlameRegressionTest::FlameRegressionTest () : TestCase ("FLAME regression test"),
7178
1a07cbb68308 mesh coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6882
diff changeset
    45
                                              m_nodes (0),
11485
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
    46
                                              m_time (Seconds (10)),
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
    47
                                              m_sentPktsCounter (0)
5826
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    48
{
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    49
}
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    50
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    51
FlameRegressionTest::~FlameRegressionTest ()
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    52
{
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    53
  delete m_nodes;
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    54
}
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    55
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6459
diff changeset
    56
void
5826
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    57
FlameRegressionTest::DoRun ()
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    58
{
8992
4fdf03b24af6 Update mesh model, tests and reference traces for new random variable usage
Tom Henderson <tomh@tomh.org>
parents: 7379
diff changeset
    59
  RngSeedManager::SetSeed (12345);
4fdf03b24af6 Update mesh model, tests and reference traces for new random variable usage
Tom Henderson <tomh@tomh.org>
parents: 7379
diff changeset
    60
  RngSeedManager::SetRun (7);
5826
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    61
  CreateNodes ();
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    62
  CreateDevices ();
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    63
  InstallApplications ();
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    64
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    65
  Simulator::Stop (m_time);
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    66
  Simulator::Run ();
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    67
  Simulator::Destroy ();
7178
1a07cbb68308 mesh coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6882
diff changeset
    68
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7256
diff changeset
    69
  CheckResults ();
5826
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    70
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    71
  delete m_nodes, m_nodes = 0;
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    72
}
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    73
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    74
void
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    75
FlameRegressionTest::CreateNodes ()
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    76
{
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    77
  m_nodes = new NodeContainer;
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    78
  m_nodes->Create (3);
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    79
  MobilityHelper mobility;
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    80
  mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
7178
1a07cbb68308 mesh coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6882
diff changeset
    81
                                 "MinX", DoubleValue (0.0),
1a07cbb68308 mesh coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6882
diff changeset
    82
                                 "MinY", DoubleValue (0.0),
1a07cbb68308 mesh coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6882
diff changeset
    83
                                 "DeltaX", DoubleValue (150),
1a07cbb68308 mesh coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6882
diff changeset
    84
                                 "DeltaY", DoubleValue (0),
1a07cbb68308 mesh coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6882
diff changeset
    85
                                 "GridWidth", UintegerValue (3),
1a07cbb68308 mesh coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6882
diff changeset
    86
                                 "LayoutType", StringValue ("RowFirst"));
5826
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    87
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    88
  mobility.Install (*m_nodes);
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    89
}
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    90
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    91
void
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    92
FlameRegressionTest::CreateDevices ()
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    93
{
9010
d6cc76205833 Update mesh test traces due to random variable perturbations
Tom Henderson <tomh@tomh.org>
parents: 8992
diff changeset
    94
  int64_t streamsUsed = 0;
5826
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    95
  // 1. setup WiFi
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    96
  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
7178
1a07cbb68308 mesh coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6882
diff changeset
    97
  // This test suite output was originally based on YansErrorRateModel
6459
d5cfe99001f0 Change default OFDM error rate model to NistErrorRateModel (issue 944)
Tom Henderson <tomh@tomh.org>
parents: 5826
diff changeset
    98
  wifiPhy.SetErrorRateModel ("ns3::YansErrorRateModel"); 
5826
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    99
  YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
9010
d6cc76205833 Update mesh test traces due to random variable perturbations
Tom Henderson <tomh@tomh.org>
parents: 8992
diff changeset
   100
  Ptr<YansWifiChannel> chan = wifiChannel.Create ();
d6cc76205833 Update mesh test traces due to random variable perturbations
Tom Henderson <tomh@tomh.org>
parents: 8992
diff changeset
   101
  wifiPhy.SetChannel (chan);
5826
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   102
  // 2. setup mesh
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   103
  MeshHelper mesh = MeshHelper::Default ();
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   104
  mesh.SetStackInstaller ("ns3::FlameStack");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7178
diff changeset
   105
  mesh.SetMacType ("RandomStart", TimeValue (Seconds (0.1)));
5826
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   106
  mesh.SetNumberOfInterfaces (1);
7178
1a07cbb68308 mesh coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6882
diff changeset
   107
  NetDeviceContainer meshDevices = mesh.Install (wifiPhy, *m_nodes);
10924
ad21b426e31d update mesh flame tests to account for wifi random variables
Tom Henderson <tomh@tomh.org>
parents: 9010
diff changeset
   108
  // Three devices, seven streams per device
9010
d6cc76205833 Update mesh test traces due to random variable perturbations
Tom Henderson <tomh@tomh.org>
parents: 8992
diff changeset
   109
  streamsUsed += mesh.AssignStreams (meshDevices, streamsUsed);
10924
ad21b426e31d update mesh flame tests to account for wifi random variables
Tom Henderson <tomh@tomh.org>
parents: 9010
diff changeset
   110
  NS_TEST_ASSERT_MSG_EQ (streamsUsed, (meshDevices.GetN () * 7), "Stream assignment unexpected value");
ad21b426e31d update mesh flame tests to account for wifi random variables
Tom Henderson <tomh@tomh.org>
parents: 9010
diff changeset
   111
  // No further streams used in the default wifi channel configuration
9010
d6cc76205833 Update mesh test traces due to random variable perturbations
Tom Henderson <tomh@tomh.org>
parents: 8992
diff changeset
   112
  streamsUsed += wifiChannel.AssignStreams (chan, streamsUsed);
10924
ad21b426e31d update mesh flame tests to account for wifi random variables
Tom Henderson <tomh@tomh.org>
parents: 9010
diff changeset
   113
  NS_TEST_ASSERT_MSG_EQ (streamsUsed, (meshDevices.GetN () * 7), "Stream assignment unexpected value");
5826
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   114
  // 3. setup TCP/IP
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   115
  InternetStackHelper internetStack;
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   116
  internetStack.Install (*m_nodes);
11015
a72b38546141 fix some additional sources of randomness in mesh tests
Tom Henderson <tomh@tomh.org>
parents: 10924
diff changeset
   117
  streamsUsed += internetStack.AssignStreams (*m_nodes, streamsUsed);
5826
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   118
  Ipv4AddressHelper address;
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   119
  address.SetBase ("10.1.1.0", "255.255.255.0");
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   120
  m_interfaces = address.Assign (meshDevices);
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   121
  // 4. write PCAP if needed
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7256
diff changeset
   122
  wifiPhy.EnablePcapAll (CreateTempDirFilename (PREFIX));
5826
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   123
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   124
}
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   125
void
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   126
FlameRegressionTest::InstallApplications ()
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   127
{
11485
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   128
  // client socket
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   129
  m_clientSocket = Socket::CreateSocket (m_nodes->Get (2), TypeId::LookupByName ("ns3::UdpSocketFactory"));
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   130
  m_clientSocket->Bind ();
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   131
  m_clientSocket->Connect (InetSocketAddress (m_interfaces.GetAddress (0), 9));
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   132
  m_clientSocket->SetRecvCallback (MakeCallback (&FlameRegressionTest::HandleReadClient, this));
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   133
  Simulator::ScheduleWithContext (m_clientSocket->GetNode ()->GetId (), Seconds (1.0),
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   134
                                  &FlameRegressionTest::SendData, this, m_clientSocket);
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   135
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   136
  // server socket
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   137
  m_serverSocket = Socket::CreateSocket (m_nodes->Get (0), TypeId::LookupByName ("ns3::UdpSocketFactory"));
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   138
  m_serverSocket->Bind (InetSocketAddress (Ipv4Address::GetAny (), 9));
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   139
  m_serverSocket->SetRecvCallback (MakeCallback (&FlameRegressionTest::HandleReadServer, this));
5826
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   140
}
7178
1a07cbb68308 mesh coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6882
diff changeset
   141
5826
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   142
void
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   143
FlameRegressionTest::CheckResults ()
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   144
{
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   145
  for (int i = 0; i < 3; ++i)
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   146
    {
7379
ff0d074f885a add support for --update-data to test.py, move test runner code to library for modular build, add support for hierarchical tests beyond the previous two-level hierarchy.
Mathieu Lacage <mathieu.lacage@gmail.com>
parents: 7256
diff changeset
   147
      NS_PCAP_TEST_EXPECT_EQ (PREFIX << "-" << i << "-1.pcap");
5826
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   148
    }
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   149
}
d0765c1313c9 Mesh:Flame: added regression test
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   150
11485
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   151
void
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   152
FlameRegressionTest::SendData (Ptr<Socket> socket)
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   153
{
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   154
  if ((Simulator::Now () < m_time) && (m_sentPktsCounter < 300))
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   155
    {
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   156
      socket->Send (Create<Packet> (20));
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   157
      m_sentPktsCounter ++;
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   158
      Simulator::ScheduleWithContext (socket->GetNode ()->GetId (), Seconds (1.1),
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   159
                                      &FlameRegressionTest::SendData, this, socket);
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   160
    }
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   161
}
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   162
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   163
void
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   164
FlameRegressionTest::HandleReadServer (Ptr<Socket> socket)
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   165
{
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   166
  Ptr<Packet> packet;
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   167
  Address from;
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   168
  while ((packet = socket->RecvFrom (from)))
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   169
    {
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   170
      packet->RemoveAllPacketTags ();
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   171
      packet->RemoveAllByteTags ();
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   172
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   173
      socket->SendTo (packet, 0, from);
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   174
    }
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   175
}
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   176
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   177
void
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   178
FlameRegressionTest::HandleReadClient (Ptr<Socket> socket)
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   179
{
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   180
  Ptr<Packet> packet;
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   181
  Address from;
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   182
  while ((packet = socket->RecvFrom (from)))
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   183
    {
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   184
    }
df37afec1b0f Bug 1941 - [mesh] Remove unnecessary dependency on Application module
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 11015
diff changeset
   185
}