OLD | NEW |
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2011 The Boeing Company | 3 * Copyright (c) 2011 The Boeing Company |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 static void StateChangeNotification (std::string context, Time now, LrWpanPhyEnu
meration oldState, LrWpanPhyEnumeration newState) | 52 static void StateChangeNotification (std::string context, Time now, LrWpanPhyEnu
meration oldState, LrWpanPhyEnumeration newState) |
53 { | 53 { |
54 NS_LOG_UNCOND (context << " state change at " << now.GetSeconds () | 54 NS_LOG_UNCOND (context << " state change at " << now.GetSeconds () |
55 << " from " << LrWpanHelper::LrWpanPhyEnumerationPrinte
r (oldState) | 55 << " from " << LrWpanHelper::LrWpanPhyEnumerationPrinte
r (oldState) |
56 << " to " << LrWpanHelper::LrWpanPhyEnumerationPrinter
(newState)); | 56 << " to " << LrWpanHelper::LrWpanPhyEnumerationPrinter
(newState)); |
57 } | 57 } |
58 | 58 |
59 int main (int argc, char *argv[]) | 59 int main (int argc, char *argv[]) |
60 { | 60 { |
61 bool verbose = false; | 61 bool verbose = false; |
| 62 bool extended = false; |
62 | 63 |
63 CommandLine cmd; | 64 CommandLine cmd; |
64 | 65 |
65 cmd.AddValue ("verbose", "turn on all log components", verbose); | 66 cmd.AddValue ("verbose", "turn on all log components", verbose); |
| 67 cmd.AddValue ("extended", "use extended addressing", extended); |
66 | 68 |
67 cmd.Parse (argc, argv); | 69 cmd.Parse (argc, argv); |
68 | 70 |
69 LrWpanHelper lrWpanHelper; | 71 LrWpanHelper lrWpanHelper; |
70 if (verbose) | 72 if (verbose) |
71 { | 73 { |
72 lrWpanHelper.EnableLogComponents (); | 74 lrWpanHelper.EnableLogComponents (); |
73 } | 75 } |
74 | 76 |
75 // Enable calculation of FCS in the trailers. Only necessary when interacting
with real devices or wireshark. | 77 // Enable calculation of FCS in the trailers. Only necessary when interacting
with real devices or wireshark. |
76 // GlobalValue::Bind ("ChecksumEnabled", BooleanValue (true)); | 78 // GlobalValue::Bind ("ChecksumEnabled", BooleanValue (true)); |
77 | 79 |
78 // Create 2 nodes, and a NetDevice for each one | 80 // Create 2 nodes, and a NetDevice for each one |
79 Ptr<Node> n0 = CreateObject <Node> (); | 81 Ptr<Node> n0 = CreateObject <Node> (); |
80 Ptr<Node> n1 = CreateObject <Node> (); | 82 Ptr<Node> n1 = CreateObject <Node> (); |
81 | 83 |
82 Ptr<LrWpanNetDevice> dev0 = CreateObject<LrWpanNetDevice> (); | 84 Ptr<LrWpanNetDevice> dev0 = CreateObject<LrWpanNetDevice> (); |
83 Ptr<LrWpanNetDevice> dev1 = CreateObject<LrWpanNetDevice> (); | 85 Ptr<LrWpanNetDevice> dev1 = CreateObject<LrWpanNetDevice> (); |
84 | 86 |
85 dev0->SetAddress (Mac16Address ("00:01")); | 87 if (!extended) |
86 dev1->SetAddress (Mac16Address ("00:02")); | 88 { |
| 89 dev0->SetAddress (Mac16Address ("00:01")); |
| 90 dev1->SetAddress (Mac16Address ("00:02")); |
| 91 } |
| 92 else |
| 93 { |
| 94 Ptr<LrWpanMac> mac0 = dev0->GetMac(); |
| 95 Ptr<LrWpanMac> mac1 = dev1->GetMac(); |
| 96 mac0->SetExtendedAddress (Mac64Address ("00:00:00:00:00:00:00:01")); |
| 97 mac1->SetExtendedAddress (Mac64Address ("00:00:00:00:00:00:00:02")); |
| 98 } |
87 | 99 |
88 // Each device must be attached to the same channel | 100 // Each device must be attached to the same channel |
89 Ptr<SingleModelSpectrumChannel> channel = CreateObject<SingleModelSpectrumChan
nel> (); | 101 Ptr<SingleModelSpectrumChannel> channel = CreateObject<SingleModelSpectrumChan
nel> (); |
90 Ptr<LogDistancePropagationLossModel> propModel = CreateObject<LogDistancePropa
gationLossModel> (); | 102 Ptr<LogDistancePropagationLossModel> propModel = CreateObject<LogDistancePropa
gationLossModel> (); |
91 Ptr<ConstantSpeedPropagationDelayModel> delayModel = CreateObject<ConstantSpee
dPropagationDelayModel> (); | 103 Ptr<ConstantSpeedPropagationDelayModel> delayModel = CreateObject<ConstantSpee
dPropagationDelayModel> (); |
92 channel->AddPropagationLossModel (propModel); | 104 channel->AddPropagationLossModel (propModel); |
93 channel->SetPropagationDelayModel (delayModel); | 105 channel->SetPropagationDelayModel (delayModel); |
94 | 106 |
95 dev0->SetChannel (channel); | 107 dev0->SetChannel (channel); |
96 dev1->SetChannel (channel); | 108 dev1->SetChannel (channel); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 lrWpanHelper.EnablePcapAll (std::string ("lr-wpan-data"), true); | 143 lrWpanHelper.EnablePcapAll (std::string ("lr-wpan-data"), true); |
132 AsciiTraceHelper ascii; | 144 AsciiTraceHelper ascii; |
133 Ptr<OutputStreamWrapper> stream = ascii.CreateFileStream ("lr-wpan-data.tr"); | 145 Ptr<OutputStreamWrapper> stream = ascii.CreateFileStream ("lr-wpan-data.tr"); |
134 lrWpanHelper.EnableAsciiAll (stream); | 146 lrWpanHelper.EnableAsciiAll (stream); |
135 | 147 |
136 // The below should trigger two callbacks when end-to-end data is working | 148 // The below should trigger two callbacks when end-to-end data is working |
137 // 1) DataConfirm callback is called | 149 // 1) DataConfirm callback is called |
138 // 2) DataIndication callback is called with value of 50 | 150 // 2) DataIndication callback is called with value of 50 |
139 Ptr<Packet> p0 = Create<Packet> (50); // 50 bytes of dummy data | 151 Ptr<Packet> p0 = Create<Packet> (50); // 50 bytes of dummy data |
140 McpsDataRequestParams params; | 152 McpsDataRequestParams params; |
141 params.m_srcAddrMode = SHORT_ADDR; | |
142 params.m_dstAddrMode = SHORT_ADDR; | |
143 params.m_dstPanId = 0; | 153 params.m_dstPanId = 0; |
144 params.m_dstAddr = Mac16Address ("00:02"); | 154 if (!extended) |
| 155 { |
| 156 params.m_srcAddrMode = SHORT_ADDR; |
| 157 params.m_dstAddrMode = SHORT_ADDR; |
| 158 params.m_dstAddr = Mac16Address ("00:02"); |
| 159 } |
| 160 else |
| 161 { |
| 162 params.m_srcAddrMode = EXT_ADDR; |
| 163 params.m_dstAddrMode = EXT_ADDR; |
| 164 params.m_dstExtAddr = Mac64Address ("00:00:00:00:00:00:00:02"); |
| 165 } |
145 params.m_msduHandle = 0; | 166 params.m_msduHandle = 0; |
146 params.m_txOptions = TX_OPTION_ACK; | 167 params.m_txOptions = TX_OPTION_ACK; |
147 // dev0->GetMac ()->McpsDataRequest (params, p0); | 168 // dev0->GetMac ()->McpsDataRequest (params, p0); |
148 Simulator::ScheduleWithContext (1, Seconds (0.0), | 169 Simulator::ScheduleWithContext (1, Seconds (0.0), |
149 &LrWpanMac::McpsDataRequest, | 170 &LrWpanMac::McpsDataRequest, |
150 dev0->GetMac (), params, p0); | 171 dev0->GetMac (), params, p0); |
151 | 172 |
152 // Send a packet back at time 2 seconds | 173 // Send a packet back at time 2 seconds |
153 Ptr<Packet> p2 = Create<Packet> (60); // 60 bytes of dummy data | 174 Ptr<Packet> p2 = Create<Packet> (60); // 60 bytes of dummy data |
154 params.m_dstAddr = Mac16Address ("00:01"); | 175 if (!extended) |
| 176 { |
| 177 params.m_dstAddr = Mac16Address ("00:01"); |
| 178 } |
| 179 else |
| 180 { |
| 181 params.m_dstExtAddr = Mac64Address ("00:00:00:00:00:00:00:01"); |
| 182 } |
155 Simulator::ScheduleWithContext (2, Seconds (2.0), | 183 Simulator::ScheduleWithContext (2, Seconds (2.0), |
156 &LrWpanMac::McpsDataRequest, | 184 &LrWpanMac::McpsDataRequest, |
157 dev1->GetMac (), params, p2); | 185 dev1->GetMac (), params, p2); |
158 | 186 |
159 Simulator::Run (); | 187 Simulator::Run (); |
160 | 188 |
161 Simulator::Destroy (); | 189 Simulator::Destroy (); |
162 return 0; | 190 return 0; |
163 } | 191 } |
OLD | NEW |