src/devices/tap-bridge/tap.h
author Andrey Mazo <mazo@iitp.ru>
Fri, 23 Apr 2010 15:09:31 +0400
changeset 6273 8d70de29d514
parent 5896 588346713573
permissions -rw-r--r--
spell check, mostly in comments.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4163
8c48682b3d42 checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     1
/**
8c48682b3d42 checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     2
 * \ingroup devices
8c48682b3d42 checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     3
 * \defgroup TapBridgeModel Tap Bridge Model
8c48682b3d42 checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     4
 *
8c48682b3d42 checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     5
 * \section TapBridgeModelOverview TapBridge Model Overview
8c48682b3d42 checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     6
 *
4176
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
     7
 * The Tap Bridge is designed to integrate "real" internet hosts (or more 
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
     8
 * precisely, hosts that support Tun/Tap devices) into ns-3 simulations.  The 
4285
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
     9
 * goal is to make it appear to a "real" host node in that it has an ns-3 net
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
    10
 * device as a local device.  The concept of a "real host" is a bit slippery
6273
8d70de29d514 spell check, mostly in comments.
Andrey Mazo <mazo@iitp.ru>
parents: 5896
diff changeset
    11
 * since the "real host" may actually be virtualized using readily available
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    12
 * technologies such as VMware, VirtualBox or OpenVZ.
4176
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
    13
 *
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
    14
 * Since we are, in essence, connecting the inputs and outputs of an ns-3 net 
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
    15
 * device to the inputs and outputs of a Linux Tap net device, we call this 
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
    16
 * arrangement a Tap Bridge.
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
    17
 *
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    18
 * There are three basic operating modes of this device available to users.  
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    19
 * Basic functionality is essentially identical, but the modes are different
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    20
 * in details regarding how the arrangement is created and configured;
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    21
 * and what devices can live on which side of the bridge.
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    22
 *
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    23
 * We call these three modes the ConfigureLocal, UseLocal and UseBridge modes.
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    24
 * The first "word" in the camel case mode identifier indicates who has the 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    25
 * responsibility for creating and configuring the taps.  For example,
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    26
 * the "Configure" in ConfigureLocal mode indicates that it is the TapBridge 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    27
 * that has responsibility for configuring the tap.  In UseLocal mode and 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    28
 * UseBridge modes, the "Use" prefix indicates that the TapBridge is asked to 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    29
 * "Use" an existing configuration.
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    30
 *
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    31
 * In other words, in ConfigureLocal mode, the TapBridge has the responsibility
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    32
 * for creating and configuring the TAP devices.  In UseBridge or UseLocal 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    33
 * modes, the user provides a configuration and the TapBridge adapts to that 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    34
 * configuration.
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    35
 *
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    36
 * \subsection TapBridgeConfigureLocalMode TapBridge ConfigureLocal Mode
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    37
 *
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    38
 * In the ConfigureLocal mode, the configuration of the tap device is ns-3 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    39
 * configuration-centric.  Configuration information is taken from a device
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    40
 * in the ns-3 simulation and a tap device matching the ns-3 attributes is 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    41
 * automatically created.  In this case, a Linux computer is made to appear as
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    42
 * if it was directly connected to a simulated ns-3 network.
4285
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
    43
 * 
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    44
 * This is illustrated below:
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    45
 *
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    46
 * \verbatim
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    47
 *     +--------+
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    48
 *     |  Linux |
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    49
 *     |  host  |                    +----------+
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    50
 *     | ------ |                    |   ghost  |
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    51
 *     |  apps  |                    |   node   |
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    52
 *     | ------ |                    | -------- |
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    53
 *     |  stack |                    |    IP    |     +----------+
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    54
 *     | ------ |                    |   stack  |     |   node   |
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    55
 *     |  TAP   |                    |==========|     | -------- |
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    56
 *     | device | <----- IPC ------> |   tap    |     |    IP    |
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    57
 *     +--------+                    |  bridge  |     |   stack  |
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    58
 *                                   | -------- |     | -------- |
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    59
 *                                   |   ns-3   |     |   ns-3   |
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    60
 *                                   |   net    |     |   net    |
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    61
 *                                   |  device  |     |  device  |
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    62
 *                                   +----------+     +----------+
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    63
 *                                        ||               ||
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    64
 *                                   +---------------------------+
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    65
 *                                   |        ns-3 channel       |
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    66
 *                                   +---------------------------+
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    67
 * \endverbatim
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    68
 *
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    69
 * In this case, the "ns-3 net device" in the "ghost node" appears as if it 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    70
 * were actually replacing the TAP device in the Linux host.  The ns-3
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    71
 * simulation creates the TAP device on the underlying Linux OS and configures
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    72
 * the IP and MAC addresses of the TAP device to match the values assigned to 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    73
 * the simulated ns-3 net device.  The "IPC" link shown above is the network
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    74
 * tap mechanism in the underlying OS.  The whole arrangement acts as a
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    75
 * conventional bridge; but a bridge between devices that happen to have the
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    76
 * same shared MAC and IP addresses.
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    77
 *
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    78
 * Here, the user is not required to provide any configuration information 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    79
 * specific to the tap.  A tap device will be created and configured by ns-3 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    80
 * according to its defaults, and the tap device will have its name assigned
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    81
 * by the underlying operating system according to its defaults.
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    82
 *
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    83
 * If the user has a requirement to access the created tap device, he or she
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    84
 * may optionally provide a "DeviceName" attribute.  In this case, the created 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    85
 * OS tap device will be named accordingly.
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    86
 *
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    87
 * The ConfigureLocal mode is the default operating mode of the Tap Bridge.
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    88
 *
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    89
 * \subsection TapBridgeUseLocalMode TapBridge UseLocal Mode
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    90
 *
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    91
 * The UseLocal mode is quite similar to the ConfigureLocal mode.  The
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    92
 * significant difference is, as the mode name implies, the TapBridge is 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    93
 * going to "Use" an existing tap device previously created and configured
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    94
 * by the user.  This mode is particularly useful when a virtualization 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    95
 * scheme automatically creates tap devices and ns-3 is used to provide 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
    96
 * simulated networks for those devices.
4285
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
    97
 *
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
    98
 * \verbatim
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
    99
 *     +--------+
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   100
 *     |  Linux |
4287
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   101
 *     |  host  |                    +----------+
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   102
 *     | ------ |                    |   ghost  |
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   103
 *     |  apps  |                    |   node   |
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   104
 *     | ------ |                    | -------- |
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   105
 *     |  stack |                    |    IP    |     +----------+
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   106
 *     | ------ |                    |   stack  |     |   node   |
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   107
 *     |  TAP   |                    |==========|     | -------- |
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   108
 *     | device | <----- IPC ------> |   tap    |     |    IP    |
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   109
 *     | MAC X  |                    |  bridge  |     |   stack  |
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   110
 *     +--------+                    | -------- |     | -------- | 
4287
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   111
 *                                   |   ns-3   |     |   ns-3   |
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   112
 *                                   |   net    |     |   net    |
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   113
 *                                   |  device  |     |  device  |
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   114
 *                                   |  MAC Y   |     |  MAC Z   |
4287
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   115
 *                                   +----------+     +----------+
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   116
 *                                        ||               ||
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   117
 *                                   +---------------------------+
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   118
 *                                   |        ns-3 channel       |
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   119
 *                                   +---------------------------+
4285
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   120
 *\endverbatim
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   121
 *
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   122
 * In this case, the pre-configured MAC address of the "Tap device" (MAC X)
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   123
 * will not be the same as that of the bridged "ns-3 net device" (MAC Y) shown
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   124
 * in the illustration above.  In order to bridge to ns-3 net devices which do
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   125
 * not support SendFrom() (especially wireless STA nodes) we impose a requirement
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   126
 * that only one Linux device (with one unique MAC address -- here X) generates 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   127
 * traffic that flows across the IPC link.  This is because the MAC addresses of
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   128
 * traffic across the IPC link will be "spoofed" or changed to make it appear to
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   129
 * Linux and ns-3 that they have the same address.  That is, traffic moving from
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   130
 * the Linux host to the ns-3 ghost node will have its MAC address changed from 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   131
 * X to Y and traffic from the ghost node to the Linux host will have its MAC 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   132
 * address changed from Y to X.  Since there is a one-to-one correspondence 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   133
 * between devices, there may only be one MAC source flowing from the Linux side.
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   134
 * This means that Linux bridges with more than one net device added are 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   135
 * incompatible with UseLocal mode.
4285
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   136
 *
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   137
 * In UseLocal mode, the user is expected to create and configure a tap device
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   138
 * completely outside the scope of the ns-3 simulation using something like:
4285
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   139
 *
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   140
 * \verbatim
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   141
 *   sudo tunctl -t tap0
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   142
 *   sudo ifconfig tap0 hw ether 08:00:2e:00:00:01
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   143
 *   sudo ifconfig tap0 10.1.1.1 netmask 255.255.255.0 up
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   144
 * \endverbatim
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   145
 *
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   146
 * To tell the TapBridge what is going on, the user will set either directly
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   147
 * into the TapBridge or via the TapBridgeHelper, the "DeviceName" attribute.
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   148
 * In the case of the configuration above, the "DeviceName" attribute would be 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   149
 * set to "tap0" and the "Mode" attribute would be set to "UseLocal".
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   150
 *
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   151
 * One particular use case for this mode is in the OpenVZ environment.  There it
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   152
 * is possible to create a Tap device on the "Hardware Node" and move it into a
6273
8d70de29d514 spell check, mostly in comments.
Andrey Mazo <mazo@iitp.ru>
parents: 5896
diff changeset
   153
 * Virtual Private Server.  If the TapBridge is able to use an existing tap device
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   154
 * it is then possible to avoid the overhead of an OS bridge in that environment.
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   155
 *
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   156
 * \subsection TapBridgeUseBridgeMode TapBridge UseBridge Mode
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   157
 *
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   158
 * The simplest mode for those familiar with Linux networking is the UseBridge 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   159
 * mode.  Again, the "Use" prefix indicates that the TapBridge is going to Use 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   160
 * an existing configuration.  In this case, the TapBridge is going to logically
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   161
 * extend a Linux bridge into ns-3.  
4285
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   162
 *
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   163
 * This is illustrated below:
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   164
 *
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   165
 * \verbatim
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   166
 *     +---------+
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   167
 *     |  Linux  |                             +----------+
4287
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   168
 *     | ------- |                             |   ghost  |
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   169
 *     |  apps   |                             |   node   |
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   170
 *     | ------- |                             | -------- |
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   171
 *     |  stack  |                             |    IP    |     +----------+
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   172
 *     | ------- | +--------+                  |   stack  |     |   node   |
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   173
 *     | Virtual | |  TAP   |                  |==========|     | -------- |
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   174
 *     | Device  | | Device | <---- IPC -----> |   tap    |     |    IP    |
4287
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   175
 *     +---------+ +--------+                  |  bridge  |     |   stack  |
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   176
 *         ||          ||                      | -------- |     | -------- |
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   177
 *     +--------------------+                  |   ns-3   |     |   ns-3   |
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   178
 *     | OS (brctl) Bridge  |                  |   net    |     |   net    |
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   179
 *     +--------------------+                  |  device  |     |  device  |
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   180
 *                                             +----------+     +----------+
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   181
 *                                                  ||               ||
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   182
 *                                             +---------------------------+
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   183
 *                                             |        ns-3 channel       |
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   184
 *                                             +---------------------------+
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   185
 * \endverbatim
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   186
 *
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   187
 * In this case, a computer running Linux applications, protocols, etc., is
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   188
 * connected to a ns-3 simulated network in such a way as to make it appear
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   189
 * to the Linux host that the TAP device is a real network device participating
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   190
 * in the Linux bridge.
4285
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   191
 *
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   192
 * In the ns-3 simulation, a TapBridge is created to match each TAP Device.
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   193
 * The name of the TAP Device is assigned to the Tap Bridge using the 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   194
 * "DeviceName" attribute.  The TapBridge then logically extends the OS bridge
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   195
 * to encompass the ns-3 net device.  
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   196
 *
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   197
 * Since this mode logically extends an OS bridge, there may be many Linux net 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   198
 * devices on the non-ns-3 side of the bridge.  Therefore, like a net device on 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   199
 * any bridge, the ns-3 net device must deal with the possibly of many source 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   200
 * addresses.  Thus, ns-3 devices must support SendFrom() 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   201
 * (NetDevice::SupportsSendFrom() must return true) in order to be configured 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   202
 * for use in UseBridge mode.
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   203
 *
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   204
 * It is expected that the user will do something like the following to
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   205
 * configure the bridge and tap completely outside ns-3:
4287
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   206
 *
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   207
 * \verbatim
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   208
 *   sudo brctl addbr mybridge
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   209
 *   sudo tunctl -t mytap
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   210
 *   sudo ifconfig mytap hw ether 00:00:00:00:00:01
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   211
 *   sudo ifconfig mytap 0.0.0.0 up
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   212
 *   sudo brctl addif mybridge mytap
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   213
 *   sudo brctl addif mybridge ...
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   214
 *   sudo ifconfig mybridge 10.1.1.1 netmask 255.255.255.0 up
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   215
 * \endverbatim
4285
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   216
 *
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   217
 * To tell the TapBridge what is going on, the user will set either directly
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   218
 * into the TapBridge or via the TapBridgeHelper, the "DeviceName" attribute.
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   219
 * In the case of the configuration above, the "DeviceName" attribute would be 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   220
 * set to "mytap" and the "Mode" attribute would be set to "UseBridge".
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   221
 *
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   222
 * This mode is especially  useful in the case of virtualization where the 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   223
 * configuration of the virtual hosts may be dictated by another system and 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   224
 * not be changable to suit ns-3.  For example, a particular VM scheme may create
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   225
 * virtual "vethx" or "vmnetx" devices that appear local to virtual hosts.  In 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   226
 * order to connect to such systems, one would need to manually create TAP devices
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   227
 * on the host system and brigde these TAP devices to the existing (VM) virtual 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   228
 * devices.  The job of the Tap Bridge in this case is to extend the bridge to
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   229
 * join a ns-3 net device.
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   230
 *
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   231
 * \subsection TapBridgeConfigureLocalOperation TapBridge ConfigureLocal Operation
4285
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   232
 * 
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   233
 * In ConfigureLocal mode, the TapBridge and therefore its associated ns-3 net
4285
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   234
 * device appears to the Linux host computer as a network device just like any
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   235
 * arbitrary "eth0" or "ath0" might appear.  The creation and configuration 
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   236
 * of the TAP device is done by the ns-3 simulation and no manual configuration
4288
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   237
 * is required by the user.  The IP addresses, MAC addresses, gateways, etc., 
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   238
 * for created TAP devices are extracted from the simulation itself by querying
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   239
 * the configuration of the ns-3 device and the TapBridge Attributes.
4176
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
   240
 *
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   241
 * Since the MAC addresses are identical on the Linux side and the ns-3 side,
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   242
 * we can use Send() on the ns-3 device which is available on all ns-3 net devices.
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   243
 * Since the MAC addresses are identical there is no requirement to hook the
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   244
 * promiscuous callback on the receive side.  Therefore there are no restrictions 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   245
 * on the kinds of net device that are usable in ConfigureLocal mode.
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   246
4176
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
   247
 * The TapBridge appears to an ns-3 simulation as a channel-less net device.
4285
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   248
 * This device must not have an IP address associated with it, but the bridged
6273
8d70de29d514 spell check, mostly in comments.
Andrey Mazo <mazo@iitp.ru>
parents: 5896
diff changeset
   249
 * (ns-3) net device must have an IP address.  Be aware that this is the inverse
4288
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   250
 * of an ns-3 BridgeNetDevice (or a conventional bridge in general) which 
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   251
 * demands that its bridge ports not have IP addresses, but allows the bridge 
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   252
 * device itself to have an IP address.  
4176
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
   253
 *
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
   254
 * The host computer will appear in a simulation as a "ghost" node that contains
4285
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   255
 * one TapBridge for each NetDevice that is being bridged.  From the perspective
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   256
 * of a simulation, the only difference between a ghost node and any other node 
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   257
 * will be the presence of the TapBridge devices.  Note however, that the 
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   258
 * presence of the TapBridge does affect the connectivity of the net device to 
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   259
 * the IP stack of the ghost node.
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   260
 *
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   261
 * Configuration of address information and the ns-3 devices is not changed in 
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   262
 * any way if a TapBridge is present.  A TapBridge will pick up the addressing
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   263
 * information from the ns-3 net device to which it is connected (its "bridged"
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   264
 * net device) and use that information to create and configure the TAP device
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   265
 * on the real host.
4176
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
   266
 *
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
   267
 * The end result of this is a situation where one can, for example, use the
4285
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   268
 * standard ping utility on a real host to ping a simulated ns-3 node.  If
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   269
 * correct routes are added to the internet host (this is expected to be done
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   270
 * automatically in future ns-3 releases), the routing systems in ns-3 will
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   271
 * enable correct routing of the packets across simulated ns-3 networks.
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   272
 * For an example of this, see the example program, tap-wifi-dumbbell.cc in 
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   273
 * the ns-3 distribution.
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   274
 *
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   275
 * The Tap Bridge lives in a kind of a gray world somewhere between a Linux host
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   276
 * and an ns-3 bridge device.  From the Linux perspective, this code appears as
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   277
 * the user mode handler for a TAP net device.  In ConfigureLocal mode, this Tap 
4288
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   278
 * device is automatically created by the ns-3 simulation.  When the Linux host 
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   279
 * writes to one of these automatically created /dev/tap devices, the write is 
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   280
 * redirected into the TapBridge that lives in the ns-3 world; and from this 
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   281
 * perspective, the packet write on Linux becomes a packet read in the Tap Bridge.
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   282
 * In other words, a Linux process writes a packet to a tap device and this packet
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   283
 * is redirected by the network tap mechanism toan ns-3 process where it is 
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   284
 * received by the TapBridge as a result of a read operation there.  The TapBridge
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   285
 * then writes the packet to the ns-3 net device to which it is bridged; and 
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   286
 * therefore it appears as if the Linux host sent a packet directly through an 
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   287
 * ns-3 net device onto an ns-3 network.
4285
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   288
 *
4288
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   289
 * In the other direction, a packet received by the ns-3 net device connected to
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   290
 * the Tap Bridge is sent via a receive callback to the TapBridge.  The 
4288
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   291
 * TapBridge then takes that packet and writes it back to the host using the 
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   292
 * network tap mechanism.  This write to the device will appear to the Linux 
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   293
 * host as if a packet has arrived on a net device; and therefore as if a packet
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   294
 * received by the ns-3 net device during a simulation has appeared on a real 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   295
 * Linux net device.
4285
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   296
 * 
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   297
 * The upshot is that the Tap Bridge appears to bridge a tap device on a
4288
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   298
 * Linux host in the "real world" to an ns-3 net device in the simulation.
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   299
 * Because the TAP device and the bridged ns-3 net device have the same MAC
6273
8d70de29d514 spell check, mostly in comments.
Andrey Mazo <mazo@iitp.ru>
parents: 5896
diff changeset
   300
 * address and the network tap IPC link is not externalized, this particular
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   301
 * kind of bridge makes it appear that a ns-3 net device is actually installed
4288
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   302
 * in the Linux host.
4287
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   303
 *
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   304
 * In order to implement this on the ns-3 side, we need a "ghost node" in the
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   305
 * simulation to hold the bridged ns-3 net device and the TapBridge.  This node
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   306
 * should not actually do anything else in the simulation since its job is 
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   307
 * simply to make the net device appear in Linux.  This is not just arbitrary 
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   308
 * policy, it is because:
4285
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   309
 *
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   310
 * - Bits sent to the TapBridge from higher layers in the ghost node (using
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   311
 *   the TapBridge Send method) are completely ignored.  The TapBridge is 
4285
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   312
 *   not, itself, connected to any network, neither in Linux nor in ns-3.  You
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   313
 *   can never send nor receive data over a TapBridge from the ghost node.
4285
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   314
 *
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   315
 * - The bridged ns-3 net device has its receive callback disconnected
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   316
 *   from the ns-3 node and reconnected to the Tap Bridge.  All data received 
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   317
 *   by a bridged device will then be sent to the Linux host and will not be 
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   318
 *   received by the node.  From the perspective of the ghost node, you can 
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   319
 *   send over this device but you cannot ever receive.
4176
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
   320
 *
4285
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   321
 * Of course, if you understand all of the issues you can take control of
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   322
 * your own destiny and do whatever you want -- we do not actively
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   323
 * prevent you from using the ghost node for anything you decide.  You
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   324
 * will be able to perform typical ns-3 operations on the ghost node if
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   325
 * you so desire.  The internet stack, for example, must be there and
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   326
 * functional on that node in order to participate in IP address
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   327
 * assignment and global routing.  However, as mentioned above,
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   328
 * interfaces talking to any TapBridge or associated bridged net devices
4285
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   329
 * will not work completely.  If you understand exactly what you are
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   330
 * doing, you can set up other interfaces and devices on the ghost node
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   331
 * and use them; or take advantage of the operational send side of the
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   332
 * bridged devices to create traffic generators.  We generally recommend
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   333
 * that you treat this node as a ghost of the Linux host and leave it to
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   334
 * itself, though.
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   335
 *
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   336
 * \subsection TapBridgeUseLocalOperation TapBridge UseLocal Mode Operation
4285
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   337
 *
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   338
 * As described in above, the TapBridge acts like a bridge from the "real" world
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   339
 * into the simulated ns-3 world.  In the case of the ConfigureLocal mode, 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   340
 * life is easy since the IP address of the Tap device matches the IP address of
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   341
 * the ns-3 device and the MAC address of the Tap device matches the MAC address
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   342
 * of the ns-3 device; and there is a one-to-one relationship between the 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   343
 * devices.
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   344
 *
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   345
 * Things are slightly complicated when a Tap device is externally configured 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   346
 * with a  different MAC address than the ns-3 net device.  The conventional way
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   347
 * to deal with this kind of difference is to use promiscuous mode in the 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   348
 * bridged device to receive packets destined for the different MAC address and 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   349
 * forward them off to Linux.  In order to move packets the other way, the 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   350
 * conventional solution is SendFrom() which allows a caller to "spoof" or change
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   351
 * the source MAC address to match the different Linux MAC address.
4285
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   352
 *
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   353
 * We do have a specific requirement to be able to bridge Linux Virtual Machines
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   354
 * onto wireless STA nodes.  Unfortunately, the 802.11 spec doesn't provide a 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   355
 * good way to implement SendFrom(), so we have to work around that problem.
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   356
 * 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   357
 * To this end, we provided the UseLocal mode of the Tap Bridge.  This mode allows 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   358
 * you approach the problem as if you were creating a bridge with a single net
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   359
 * device.  A single allowed address on the Linux side is remembered in the 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   360
 * TapBridge, and all packets coming from the Linux side are repeated out the 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   361
 * ns-3 side using the ns-3 device MAC source address.  All packets coming in 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   362
 * from the ns-3 side are repeated out the Linux side using the remembered MAC 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   363
 * address.  This allows us to use Send() on the ns-3 device side which is 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   364
 * available on all ns-3 net devices.
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   365
 * 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   366
 * UseLocal mode is identical to the ConfigureLocal mode except for the creation
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   367
 * and configuration of the tap device and the MAC address spoofing.
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   368
 * 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   369
 * \subsection TapBridgeUseBridgeOperation TapBridge UseBridge Operation
4285
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   370
 *
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   371
 * As described in the ConfigureLocal mode section, when the Linux host writes to 
4285
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   372
 * one of the /dev/tap devices, the write is redirected into the TapBridge
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   373
 * that lives in the ns-3 world.  In the case of the UseBridge mode, these
4288
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   374
 * packets will need to be sent out on the ns-3 network as if they were sent on
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   375
 * a device participating in the Linux bridge.  This means calling the 
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   376
 * SendFrom() method on the bridged device and providing the source MAC address
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   377
 * found in the packet.
4285
2b197a6b4460 first cut at enabling OpenVZ scenario
Craig Dowell <craigdo@ee.washington.edu>
parents: 4176
diff changeset
   378
 *
4288
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   379
 * In the other direction, a packet received by an ns-3 net device is hooked
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   380
 * via callback to the TapBridge.  This must be done in promiscuous mode since
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   381
 * the goal is to bridge the ns-3 net device onto the OS (brctl) bridge of 
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   382
 * which the TAP device is a part.
4287
9dafedaa8eb2 Clean up some tap bridge dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4285
diff changeset
   383
 *
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   384
 * For these reasons, only ns-3 net devices that support SendFrom() and have a
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   385
 * hookable promiscuous receive callback are allowed to participate in UseBridge
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   386
 * mode TapBridge configurations.
4288
8a999429091b a little more dox
Craig Dowell <craigdo@ee.washington.edu>
parents: 4287
diff changeset
   387
 *
4176
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
   388
 * \section TapBridgeChannelModel Tap Bridge Channel Model
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
   389
 *
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
   390
 * There is no channel model associated with the Tap Bridge.  In fact, the
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
   391
 * intention is make it appear that the real internet host is connected to 
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
   392
 * the channel of the bridged net device.
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
   393
 *
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
   394
 * \section TapBridgeTracingModel Tap Bridge Tracing Model
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
   395
 *
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
   396
 * Unlike most ns-3 devices, the TapBridge does not provide any standard trace
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
   397
 * sources.  This is because the bridge is an intermediary that is essentially
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
   398
 * one function call away from the bridged device.  We expect that the trace
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
   399
 * hooks in the bridged device will be sufficient for most users,
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
   400
 *
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   401
 * \section TapBridgeUsage Using the TapBridge
4176
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
   402
 *
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
   403
 * We expect that most users will interact with the TapBridge device through
0246ffdff112 cleanup, doxygen, prepare for review
Craig Dowell <craigdo@ee.washington.edu>
parents: 4163
diff changeset
   404
 * the TapBridgeHelper.  Users of other helper classes, such as CSMA or Wifi,
5896
588346713573 update tap.h documentation which was incredibly stale
Craig Dowell <craigdo@ee.washington.edu>
parents: 4288
diff changeset
   405
 * should be comfortable with the idioms used there.
4163
8c48682b3d42 checkpoint tap development
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   406
 */