diff -r 58182a1561cc -r db72c0e7743e src/devices/wifi/wifi-helper.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/devices/wifi/wifi-helper.cc Sat Mar 01 21:21:53 2008 +0100 @@ -0,0 +1,114 @@ +#include "wifi-helper.h" +#include "wifi-net-device.h" +#include "wifi-mac.h" +#include "wifi-phy.h" +#include "wifi-remote-station-manager.h" +#include "wifi-channel.h" +#include "ns3/mobility-model.h" +#include "ns3/log.h" + +NS_LOG_COMPONENT_DEFINE ("WifiHelper"); + +namespace ns3 { + +WifiHelper::WifiHelper () +{ + m_stationManager.SetTypeId ("ArfWifiManager"); + m_phy.SetTypeId ("WifiPhy"); + m_mac.SetTypeId ("AdhocWifiMac"); +} + +void +WifiHelper::SetRemoteStationManager (std::string type, + std::string n0, Attribute v0, + std::string n1, Attribute v1, + std::string n2, Attribute v2, + std::string n3, Attribute v3, + std::string n4, Attribute v4, + std::string n5, Attribute v5, + std::string n6, Attribute v6, + std::string n7, Attribute v7) +{ + m_stationManager = ObjectFactory (); + m_stationManager.SetTypeId (type); + m_stationManager.Set (n0, v0); + m_stationManager.Set (n1, v1); + m_stationManager.Set (n2, v2); + m_stationManager.Set (n3, v3); + m_stationManager.Set (n4, v4); + m_stationManager.Set (n5, v5); + m_stationManager.Set (n6, v6); + m_stationManager.Set (n7, v7); +} + +void +WifiHelper::SetMac (std::string type, + std::string n0, Attribute v0, + std::string n1, Attribute v1, + std::string n2, Attribute v2, + std::string n3, Attribute v3, + std::string n4, Attribute v4, + std::string n5, Attribute v5, + std::string n6, Attribute v6, + std::string n7, Attribute v7) +{ + m_mac = ObjectFactory (); + m_mac.SetTypeId (type); + m_mac.Set (n0, v0); + m_mac.Set (n1, v1); + m_mac.Set (n2, v2); + m_mac.Set (n3, v3); + m_mac.Set (n4, v4); + m_mac.Set (n5, v5); + m_mac.Set (n6, v6); + m_mac.Set (n7, v7); +} + +void +WifiHelper::SetPhy (std::string type, + std::string n0, Attribute v0, + std::string n1, Attribute v1, + std::string n2, Attribute v2, + std::string n3, Attribute v3, + std::string n4, Attribute v4, + std::string n5, Attribute v5, + std::string n6, Attribute v6, + std::string n7, Attribute v7) +{ + m_phy = ObjectFactory (); + m_phy.SetTypeId (type); + m_phy.Set (n0, v0); + m_phy.Set (n1, v1); + m_phy.Set (n2, v2); + m_phy.Set (n3, v3); + m_phy.Set (n4, v4); + m_phy.Set (n5, v5); + m_phy.Set (n6, v6); + m_phy.Set (n7, v7); +} + +NetDeviceContainer +WifiHelper::Build (NodeContainer c) const +{ + Ptr channel = CreateObjectWith (); + return Build (c, channel); +} +NetDeviceContainer +WifiHelper::Build (NodeContainer c, Ptr channel) const +{ + NetDeviceContainer devices; + for (NodeContainer::Iterator i = c.Begin (); i != c.End (); i++) + { + Ptr node = *i; + Ptr device = CreateObject (); + Ptr manager = m_stationManager.Create (); + Ptr mac = m_mac.Create (); + Ptr phy = m_phy.Create (); + device->Setup (node, mac, phy, manager, channel); + node->AddDevice (device); + devices.Add (device); + NS_LOG_DEBUG ("node="<