00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "wifi-helper.h"
00021 #include "ns3/wifi-net-device.h"
00022 #include "ns3/wifi-mac.h"
00023 #include "ns3/wifi-phy.h"
00024 #include "ns3/wifi-remote-station-manager.h"
00025 #include "ns3/wifi-channel.h"
00026 #include "ns3/yans-wifi-channel.h"
00027 #include "ns3/propagation-delay-model.h"
00028 #include "ns3/propagation-loss-model.h"
00029 #include "ns3/mobility-model.h"
00030 #include "ns3/log.h"
00031 #include "ns3/pcap-writer.h"
00032 #include "ns3/config.h"
00033 #include "ns3/simulator.h"
00034
00035
00036
00037 NS_LOG_COMPONENT_DEFINE ("WifiHelper");
00038
00039 namespace ns3 {
00040
00041 WifiPhyHelper::~WifiPhyHelper ()
00042 {}
00043
00044
00045 WifiHelper::WifiHelper ()
00046 {}
00047
00048 WifiHelper
00049 WifiHelper::Default (void)
00050 {
00051 WifiHelper helper;
00052 helper.SetRemoteStationManager ("ns3::ArfWifiManager");
00053 helper.SetMac ("ns3::AdhocWifiMac");
00054 return helper;
00055 }
00056
00057 void
00058 WifiHelper::SetRemoteStationManager (std::string type,
00059 std::string n0, const AttributeValue &v0,
00060 std::string n1, const AttributeValue &v1,
00061 std::string n2, const AttributeValue &v2,
00062 std::string n3, const AttributeValue &v3,
00063 std::string n4, const AttributeValue &v4,
00064 std::string n5, const AttributeValue &v5,
00065 std::string n6, const AttributeValue &v6,
00066 std::string n7, const AttributeValue &v7)
00067 {
00068 m_stationManager = ObjectFactory ();
00069 m_stationManager.SetTypeId (type);
00070 m_stationManager.Set (n0, v0);
00071 m_stationManager.Set (n1, v1);
00072 m_stationManager.Set (n2, v2);
00073 m_stationManager.Set (n3, v3);
00074 m_stationManager.Set (n4, v4);
00075 m_stationManager.Set (n5, v5);
00076 m_stationManager.Set (n6, v6);
00077 m_stationManager.Set (n7, v7);
00078 }
00079
00080 void
00081 WifiHelper::SetMac (std::string type,
00082 std::string n0, const AttributeValue &v0,
00083 std::string n1, const AttributeValue &v1,
00084 std::string n2, const AttributeValue &v2,
00085 std::string n3, const AttributeValue &v3,
00086 std::string n4, const AttributeValue &v4,
00087 std::string n5, const AttributeValue &v5,
00088 std::string n6, const AttributeValue &v6,
00089 std::string n7, const AttributeValue &v7)
00090 {
00091 m_mac = ObjectFactory ();
00092 m_mac.SetTypeId (type);
00093 m_mac.Set (n0, v0);
00094 m_mac.Set (n1, v1);
00095 m_mac.Set (n2, v2);
00096 m_mac.Set (n3, v3);
00097 m_mac.Set (n4, v4);
00098 m_mac.Set (n5, v5);
00099 m_mac.Set (n6, v6);
00100 m_mac.Set (n7, v7);
00101 }
00102
00103 NetDeviceContainer
00104 WifiHelper::Install (const WifiPhyHelper &phyHelper, NodeContainer c) const
00105 {
00106 NetDeviceContainer devices;
00107 for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
00108 {
00109 Ptr<Node> node = *i;
00110 Ptr<WifiNetDevice> device = CreateObject<WifiNetDevice> ();
00111 Ptr<WifiRemoteStationManager> manager = m_stationManager.Create<WifiRemoteStationManager> ();
00112 Ptr<WifiMac> mac = m_mac.Create<WifiMac> ();
00113 Ptr<WifiPhy> phy = phyHelper.Create (node, device);
00114 mac->SetAddress (Mac48Address::Allocate ());
00115 device->SetMac (mac);
00116 device->SetPhy (phy);
00117 device->SetRemoteStationManager (manager);
00118 node->AddDevice (device);
00119 devices.Add (device);
00120 NS_LOG_DEBUG ("node="<<node<<", mob="<<node->GetObject<MobilityModel> ());
00121 }
00122 return devices;
00123 }
00124 NetDeviceContainer
00125 WifiHelper::Install (const WifiPhyHelper &phy, Ptr<Node> node) const
00126 {
00127 return Install (phy, NodeContainer (node));
00128 }
00129
00130
00131 }