5 #include "adhoc-wifi-mac.h" |
5 #include "adhoc-wifi-mac.h" |
6 #include "yans-wifi-phy.h" |
6 #include "yans-wifi-phy.h" |
7 #include "arf-wifi-manager.h" |
7 #include "arf-wifi-manager.h" |
8 #include "propagation-delay-model.h" |
8 #include "propagation-delay-model.h" |
9 #include "propagation-loss-model.h" |
9 #include "propagation-loss-model.h" |
|
10 #include "error-rate-model.h" |
10 #include "ns3/static-mobility-model.h" |
11 #include "ns3/static-mobility-model.h" |
11 #include "ns3/node.h" |
12 #include "ns3/node.h" |
12 #include "ns3/simulator.h" |
13 #include "ns3/simulator.h" |
13 #include "ns3/test.h" |
14 #include "ns3/test.h" |
14 #include "ns3/object-factory.h" |
15 #include "ns3/object-factory.h" |
21 WifiTest (); |
22 WifiTest (); |
22 |
23 |
23 virtual bool RunTests (void); |
24 virtual bool RunTests (void); |
24 private: |
25 private: |
25 void RunOne (void); |
26 void RunOne (void); |
26 void CreateOne (Vector pos, Ptr<WifiChannel> channel); |
27 void CreateOne (Vector pos, Ptr<YansWifiChannel> channel); |
27 void SendOnePacket (Ptr<WifiNetDevice> dev); |
28 void SendOnePacket (Ptr<WifiNetDevice> dev); |
28 |
29 |
29 ObjectFactory m_manager; |
30 ObjectFactory m_manager; |
30 ObjectFactory m_mac; |
31 ObjectFactory m_mac; |
31 ObjectFactory m_propDelay; |
32 ObjectFactory m_propDelay; |
41 Ptr<Packet> p = Create<Packet> (); |
42 Ptr<Packet> p = Create<Packet> (); |
42 dev->Send (p, dev->GetBroadcast (), 1); |
43 dev->Send (p, dev->GetBroadcast (), 1); |
43 } |
44 } |
44 |
45 |
45 void |
46 void |
46 WifiTest::CreateOne (Vector pos, Ptr<WifiChannel> channel) |
47 WifiTest::CreateOne (Vector pos, Ptr<YansWifiChannel> channel) |
47 { |
48 { |
48 Ptr<Node> node = CreateObject<Node> (); |
49 Ptr<Node> node = CreateObject<Node> (); |
49 Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> (); |
50 Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> (); |
50 |
51 |
51 Ptr<WifiMac> mac = m_mac.Create<WifiMac> (); |
52 Ptr<WifiMac> mac = m_mac.Create<WifiMac> (); |
52 Ptr<StaticMobilityModel> mobility = CreateObject<StaticMobilityModel> (); |
53 Ptr<StaticMobilityModel> mobility = CreateObject<StaticMobilityModel> (); |
53 Ptr<WifiPhy> phy = channel->CreatePhy (dev, mobility, UnsafeAttributeList ()); |
54 Ptr<YansWifiPhy> phy = CreateObject<YansWifiPhy> (); |
|
55 Ptr<ErrorRateModel> error = CreateObject<ErrorRateModel> (); |
|
56 phy->SetErrorRateModel (error); |
|
57 phy->SetChannel (channel); |
|
58 phy->SetDevice (dev); |
|
59 phy->SetMobility (node); |
54 Ptr<WifiRemoteStationManager> manager = m_manager.Create<WifiRemoteStationManager> (); |
60 Ptr<WifiRemoteStationManager> manager = m_manager.Create<WifiRemoteStationManager> (); |
55 |
61 |
56 mobility->SetPosition (pos); |
62 mobility->SetPosition (pos); |
57 node->AggregateObject (mobility); |
63 node->AggregateObject (mobility); |
58 mac->SetAddress (Mac48Address::Allocate ()); |
64 mac->SetAddress (Mac48Address::Allocate ()); |
59 dev->SetMac (mac); |
65 dev->SetMac (mac); |
60 dev->SetPhy (phy); |
66 dev->SetPhy (phy); |
61 dev->SetRemoteStationManager (manager); |
67 dev->SetRemoteStationManager (manager); |
62 dev->SetChannel (channel); |
|
63 node->AddDevice (dev); |
68 node->AddDevice (dev); |
64 |
69 |
65 Simulator::Schedule (Seconds (1.0), &WifiTest::SendOnePacket, this, dev); |
70 Simulator::Schedule (Seconds (1.0), &WifiTest::SendOnePacket, this, dev); |
66 } |
71 } |
67 |
72 |