examples/tap-wifi-dumbbell.cc
author Craig Dowell <craigdo@ee.washington.edu>
Tue, 10 Mar 2009 23:47:55 -0700
changeset 4264 9d2e96c4e6e4
parent 4239 f03281563857
child 4291 141f01bbfa8b
permissions -rw-r--r--
Piles of changes for tracing rework
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4177
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     2
/*
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     3
 * This program is free software; you can redistribute it and/or modify
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     4
 * it under the terms of the GNU General Public License version 2 as
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     5
 * published by the Free Software Foundation;
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     6
 *
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     7
 * This program is distributed in the hope that it will be useful,
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    10
 * GNU General Public License for more details.
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    11
 *
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    12
 * You should have received a copy of the GNU General Public License
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    13
 * along with this program; if not, write to the Free Software
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    15
 */
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    16
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    17
// Network topology
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    18
//
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    19
//  +----------+                                                                  
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    20
//  | external |                                                                  
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    21
//  |  Linux   |                                                                  
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    22
//  |   Host   |                                                                  
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    23
//  |  "left"  |                                                                  
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    24
//  +----------+                                                                  
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    25
//       |           n0                n3                n4
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    26
//       |       +--------+     +------------+     +------------+
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    27
//       +-------|  tap   |     |            |     |            |
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    28
//               | bridge | ... |            |     |            |
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    29
//               +--------+     +------------+     +------------+
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    30
//               |  Wifi  |     | Wifi | P2P |-----| P2P | CSMA |
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    31
//               +--------+     +------+-----+     +-----+------+
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    32
//                   |              |           ^           |
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    33
//                 ((*))          ((*))         |           |         
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    34
//                                          P2P 10.1.2      |         
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    35
//                 ((*))          ((*))                     |    n5  n6   n7
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    36
//                   |              |                       |     |   |    |
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    37
//                  n1             n2                       ================
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    38
//                     Wifi 10.1.1                           CSMA LAN 10.1.3
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    39
//
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    40
// The Wifi device on node zero is:  10.1.1.1
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    41
// The Wifi device on node one is:   10.1.1.2
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    42
// The Wifi device on node two is:   10.1.1.3
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    43
// The Wifi device on node three is: 10.1.1.4
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    44
// The P2P device on node three is:  10.1.2.1
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    45
// The P2P device on node four is:   10.1.2.2
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    46
// The CSMA device on node four is:  10.1.3.1
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    47
// The CSMA device on node five is:  10.1.3.2
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    48
// The CSMA device on node six is:   10.1.3.3
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    49
// The CSMA device on node seven is: 10.1.3.4
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    50
//
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    51
// Some simple things to do:
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    52
//
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    53
// 1) Ping one of the simulated nodes on the left side of the topology.
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    54
//
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    55
//    ./waf --run tap-wifi-dumbbell&
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    56
//    ping 10.1.1.3
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    57
//
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    58
// 2) Configure a route in the linux host and ping once of the nodes on the 
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    59
//    right, across the point-to-point link.  You will see relatively large
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    60
//    delays due to CBR background traffic on the point-to-point (see next
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    61
//    item).
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    62
//
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    63
//    ./waf --run tap-wifi-dumbbell&
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    64
//    sudo route add -net 10.1.3.0 netmask 255.255.255.0 dev left gw 10.1.1.2
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    65
//    ping 10.1.3.4
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    66
//
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    67
//    Take a look at the pcap traces and note that the timing reflects the 
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    68
//    addition of the significant delay and low bandwidth configured on the 
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    69
//    point-to-point link along with the high traffic.
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    70
//
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    71
// 3) Fiddle with the background CBR traffic across the point-to-point 
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    72
//    link and watch the ping timing change.  The OnOffApplication "DataRate"
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    73
//    attribute defaults to 500kb/s and the "PacketSize" Attribute defaults
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    74
//    to 512.  The point-to-point "DataRate" is set to 512kb/s in the script,
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    75
//    so in the default case, the link is pretty full.  This should be 
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    76
//    reflected in large delays seen by ping.  You can crank down the CBR 
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    77
//    traffic data rate and watch the ping timing change dramatically.
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    78
//
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    79
//    ./waf --run "tap-wifi-dumbbell --ns3::OnOffApplication::DataRate=100kb/s"&
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    80
//    sudo route add -net 10.1.3.0 netmask 255.255.255.0 dev left gw 10.1.1.2
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    81
//    ping 10.1.3.4
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    82
//
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    83
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    84
#include <iostream>
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    85
#include <fstream>
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    86
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    87
#include "ns3/simulator-module.h"
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    88
#include "ns3/node-module.h"
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    89
#include "ns3/core-module.h"
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    90
#include "ns3/wifi-module.h"
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    91
#include "ns3/helper-module.h"
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    92
#include "ns3/global-routing-module.h"
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    93
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    94
using namespace ns3;
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    95
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    96
NS_LOG_COMPONENT_DEFINE ("TapDumbbellExample");
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    97
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    98
int 
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    99
main (int argc, char *argv[])
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   100
{
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   101
  CommandLine cmd;
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   102
  cmd.Parse (argc, argv);
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   103
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   104
  GlobalValue::Bind ("SimulatorImplementationType", StringValue ("ns3::RealtimeSimulatorImpl"));
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   105
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   106
  Config::SetDefault ("ns3::Ipv4L3Protocol::CalcChecksum", BooleanValue (true)); 
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   107
  Config::SetDefault ("ns3::Icmpv4L4Protocol::CalcChecksum", BooleanValue (true)); 
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   108
  Config::SetDefault ("ns3::TcpL4Protocol::CalcChecksum", BooleanValue (true)); 
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   109
  Config::SetDefault ("ns3::UdpL4Protocol::CalcChecksum", BooleanValue (true)); 
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   110
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   111
  //
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   112
  // The topology has a Wifi network of four nodes on the left side.  We'll make
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   113
  // node zero the AP and have the other three will be the STAs.
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   114
  //
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   115
  NodeContainer nodesLeft;
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   116
  nodesLeft.Create (4);
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   117
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   118
  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   119
  YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   120
  wifiPhy.SetChannel (wifiChannel.Create ());
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   121
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   122
  Ssid ssid = Ssid ("left");
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   123
  WifiHelper wifi = WifiHelper::Default ();
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   124
  wifi.SetRemoteStationManager ("ns3::ArfWifiManager");
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   125
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   126
  wifi.SetMac ("ns3::NqapWifiMac", 
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   127
               "Ssid", SsidValue (ssid), 
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   128
               "BeaconGeneration", BooleanValue (true), 
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   129
               "BeaconInterval", TimeValue (Seconds (2.5)));
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   130
  NetDeviceContainer devicesLeft = wifi.Install (wifiPhy, nodesLeft.Get (0));
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   131
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   132
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   133
  wifi.SetMac ("ns3::NqstaWifiMac", 
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   134
               "Ssid", SsidValue (ssid), 
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   135
               "ActiveProbing", BooleanValue (false));
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   136
  devicesLeft.Add (wifi.Install (wifiPhy, NodeContainer (nodesLeft.Get (1), nodesLeft.Get (2), nodesLeft.Get (3))));
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   137
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   138
  MobilityHelper mobility;
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   139
  mobility.Install (nodesLeft);
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   140
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   141
  InternetStackHelper internetLeft;
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   142
  internetLeft.Install (nodesLeft);
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   143
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   144
  Ipv4AddressHelper ipv4Left;
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   145
  ipv4Left.SetBase ("10.1.1.0", "255.255.255.0");
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   146
  Ipv4InterfaceContainer interfacesLeft = ipv4Left.Assign (devicesLeft);
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   147
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   148
  TapBridgeHelper bridgeLeft (interfacesLeft.GetAddress (1));
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   149
  bridgeLeft.SetAttribute ("DeviceName", StringValue ("left"));
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   150
  bridgeLeft.Install (nodesLeft.Get (0), devicesLeft.Get (0));
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   151
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   152
  //
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   153
  // Now, create the right side.
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   154
  //
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   155
  NodeContainer nodesRight;
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   156
  nodesRight.Create (4);
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   157
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   158
  CsmaHelper csmaRight;
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   159
  csmaRight.SetChannelAttribute ("DataRate", DataRateValue (5000000));
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   160
  csmaRight.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   161
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   162
  NetDeviceContainer devicesRight = csmaRight.Install (nodesRight);
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   163
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   164
  InternetStackHelper internetRight;
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   165
  internetRight.Install (nodesRight);
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   166
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   167
  Ipv4AddressHelper ipv4Right;
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   168
  ipv4Right.SetBase ("10.1.3.0", "255.255.255.0");
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   169
  Ipv4InterfaceContainer interfacesRight = ipv4Right.Assign (devicesRight);
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   170
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   171
  //
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   172
  // Stick in the point-to-point line between the sides.
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   173
  //
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   174
  PointToPointHelper p2p;
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   175
  p2p.SetDeviceAttribute ("DataRate", StringValue ("512kbps"));
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   176
  p2p.SetChannelAttribute ("Delay", StringValue ("10ms"));
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   177
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   178
  NodeContainer nodes = NodeContainer (nodesLeft.Get(3), nodesRight.Get (0));
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   179
  NetDeviceContainer devices = p2p.Install (nodes);
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   180
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   181
  Ipv4AddressHelper ipv4;
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   182
  ipv4.SetBase ("10.1.2.0", "255.255.255.192");
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   183
  Ipv4InterfaceContainer interfaces = ipv4.Assign (devices);
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   184
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   185
  //
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   186
  // Simulate some CBR traffic over the point-to-point link
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   187
  //
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   188
  uint16_t port = 9;   // Discard port (RFC 863)
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   189
  OnOffHelper onoff ("ns3::UdpSocketFactory", InetSocketAddress (interfaces.GetAddress (1), port));
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   190
  onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   191
  onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   192
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   193
  ApplicationContainer apps = onoff.Install (nodesLeft.Get (3));
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   194
  apps.Start (Seconds (1.0));
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   195
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   196
  // Create a packet sink to receive these packets
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   197
  PacketSinkHelper sink ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), port));
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   198
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   199
  apps = sink.Install (nodesRight.Get (0));
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   200
  apps.Start (Seconds (1.0));
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   201
4264
9d2e96c4e6e4 Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents: 4239
diff changeset
   202
  CsmaHelper::EnablePcapAll ("tap-dumbbell", false);
4177
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   203
  GlobalRouteManager::PopulateRoutingTables ();
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   204
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   205
  Simulator::Stop (Seconds (60.));
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   206
  Simulator::Run ();
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   207
  Simulator::Destroy ();
1212830d6f76 add a wifi example for the tap bridge
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   208
}