00001 /** 00002 * \ingroup devices 00003 * \defgroup EmuModel Emulated Net Device Model 00004 * 00005 * \section EmuModelOverview Emulated Net Device Model Overview 00006 * 00007 * The emulated net device allows a simulation node to send and receive packets 00008 * a real network. 00009 * 00010 * The emulated net device relies on a specified interface being in promiscuous 00011 * mode. It opens a raw socket and binds to that interface. We perform MAC 00012 * spoofing to separate simulation network traffic from other network traffic 00013 * that may be flowing to and from the host. 00014 * 00015 * Normally, the use case for emulated net devices is in collections of 00016 * small simulations that connect to the outside world through specific 00017 * interfaces. For example, one could construct a number of virtual 00018 * machines and connect them via a host-only network. To use the emulated 00019 * net device, you would need to set all of the host-only interfaces in 00020 * promiscuous mode and provide an appropriate device name, "eth1" for example. 00021 * 00022 * One could also use the emulated net device in a testbed situation 00023 * where the host on which the simulation is running has a specific interface 00024 * of interest which drives the testbed hardware. You would also need to set 00025 * this specific interface into promiscuous mode and provide an appropriate 00026 * device name to the ns-3 emulated net device. 00027 * 00028 * The emulated net device only works if the underlying interface is up in 00029 * promiscuous mode. We could just turn it on, but the situation is that we 00030 * expect the other considerations listed above to have been dealt with. 00031 * To verify that these issues are dealt with, we just make sure that the end 00032 * result of that process has taken place and that the specified interface is 00033 * in promiscuous mode. 00034 * 00035 * Packets will be sent out over the device, but we use MAC spoofing. The 00036 * MAC addresses will be generated using the Organizationally Unique Identifier 00037 * (OUI) 00:00:00 as a base. This vendor code is not assigned to any 00038 * organization and so should not conflict with any real hardware. 00039 * 00040 * It is always up to you to determine that using these MAC addresses is 00041 * okay on your network and won't conflict with anything else (including another 00042 * simulation using emu devices) on your network. If you are using the 00043 * emulated net device in separate simulations you must consider global MAC 00044 * address assignment issues and ensure that MAC addresses are unique across 00045 * all simulations. The emulated net device respects the MAC address provided 00046 * in the SetAddress method so you can do this manually. For larger simulations, 00047 * you may want to set the OUI in the MAC address allocation function. 00048 * 00049 * IP addresses corresponding to the emulated net devices are the addresses 00050 * generated in the simulation, which are generated in the usual way via helper 00051 * functions. 00052 * 00053 * The emulated net device comes with a helper function as all ns-3 devices do. 00054 * One unique aspect is that there is no channel associated with the underlying 00055 * medium. We really have no idea what this medium is, and so have not made an 00056 * effort to model it abstractly. The primary thing to be aware of is the 00057 * implication this has for static global routing. The global router module 00058 * attempts to walk the channels looking for adjacent networks. Since there 00059 * is no channel, the global router will be unable to do this. 00060 * 00061 * \section EmuTracingModel Emulated Net Device Tracing Model 00062 * 00063 * Like all ns-3 devices, the Emu Model provides a number of trace sources. 00064 * These trace sources can be hooked using your own custom trace code, or you 00065 * can use our helper functions to arrange for tracing to be enabled on devices 00066 * you specify. 00067 * 00068 * \subsection EmuTracingModelUpperHooks Upper-Level (MAC) Hooks 00069 * 00070 * From the point of view of tracing in the net device, there are several 00071 * interesting points to insert trace hooks. A convention inherited from other 00072 * simulators is that packets destined for transmission onto attached networks 00073 * pass through a single "transmit queue" in the net device. We provide trace 00074 * hooks at this point in packet flow, which corresponds (abstractly) only to a 00075 * transition from the network to data link layer, and call them collectively 00076 * the device MAC hooks. 00077 * 00078 * When a packet is sent to the Emu net device for transmission it always 00079 * passes through the transmit queue. The transmit queue in the EmuNetDevice 00080 * inherits from Queue, and therefore inherits three trace sources: 00081 * 00082 * - An Enqueue operation source (see Queue::m_traceEnqueue); 00083 * - A Dequeue operation source (see Queue::m_traceDequeue); 00084 * - A Drop operation source (see Queue::m_traceDrop). 00085 * 00086 * The upper-level (MAC) trace hooks for the EmuNetDevice are, in fact, 00087 * exactly these three trace sources on the single transmit queue of the device. 00088 * 00089 * The m_traceEnqueue event is triggered when a packet is placed on the transmit 00090 * queue. This happens at the time that ns3::EmuNetDevice::Send or 00091 * ns3::EmuNetDevice::SendFrom is called by a higher layer to queue a packet for 00092 * transmission. 00093 * 00094 * The m_traceDequeue event is triggered when a packet is removed from the 00095 * transmit queue. Dequeues from the transmit queue happen immediately after 00096 * the packet was enqueued and only indicate that the packet is about to be 00097 * sent to an underlying raw socket. The actual time at which the packet is 00098 * sent out on the wire is not available. 00099 * 00100 * \subsection EmuTracingModelLowerHooks Lower-Level (PHY) Hooks 00101 * 00102 * Similar to the upper level trace hooks, there are trace hooks available at 00103 * the lower levels of the net device. We call these the PHY hooks. These 00104 * events fire from the device methods that talk directly to the underlying 00105 * raw socket. 00106 * 00107 * The trace source m_dropTrace is not used in the Emu net device since that 00108 * is really the business of the underlying "real" device driver. 00109 * 00110 * The other low-level trace source fires on reception of an accepted packet 00111 * (see ns3::EmuNetDevice::m_rxTrace). A packet is accepted if it is destined 00112 * for the broadcast address, a multicast address, or to the MAC address 00113 * assigned to the Emu net device. 00114 */