| 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) 2005,2006 INRIA | 3 * Copyright (c) 2005,2006 INRIA |
| 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 236 case MacLowTransmissionParameters::ACK_FAST: | 236 case MacLowTransmissionParameters::ACK_FAST: |
| 237 os << "fast"; | 237 os << "fast"; |
| 238 break; | 238 break; |
| 239 case MacLowTransmissionParameters::ACK_SUPER_FAST: | 239 case MacLowTransmissionParameters::ACK_SUPER_FAST: |
| 240 os << "super-fast"; | 240 os << "super-fast"; |
| 241 break; | 241 break; |
| 242 } | 242 } |
| 243 os << "]"; | 243 os << "]"; |
| 244 return os; | 244 return os; |
| 245 } | 245 } |
| 246 | |
| 247 | |
| 248 /*************************************************************** | |
| 249 * Listener for PHY events. Forwards to MacLow | |
| 250 ***************************************************************/ | |
| 251 | |
| 252 | |
| 253 class PhyMacLowListener : public ns3::WifiPhyListener { | |
| 254 public: | |
| 255 PhyMacLowListener (ns3::MacLow *macLow) | |
| 256 : m_macLow (macLow) {} | |
| 257 virtual ~PhyMacLowListener () {} | |
| 258 virtual void NotifyRxStart (Time duration) {} | |
| 259 virtual void NotifyRxEndOk (void) {} | |
| 260 virtual void NotifyRxEndError (void) {} | |
| 261 virtual void NotifyTxStart (Time duration) {} | |
| 262 virtual void NotifyMaybeCcaBusyStart (Time duration) {} | |
| 263 virtual void NotifySwitchingStart (Time duration) { | |
| 264 m_macLow->NotifySwitchingStartNow (duration); | |
| 265 } | |
| 266 private: | |
| 267 ns3::MacLow *m_macLow; | |
| 268 }; | |
| 269 | |
| 246 | 270 |
| 247 MacLow::MacLow () | 271 MacLow::MacLow () |
| 248 : m_normalAckTimeoutEvent (), | 272 : m_normalAckTimeoutEvent (), |
| 249 m_fastAckTimeoutEvent (), | 273 m_fastAckTimeoutEvent (), |
| 250 m_superFastAckTimeoutEvent (), | 274 m_superFastAckTimeoutEvent (), |
| 251 m_fastAckFailedTimeoutEvent (), | 275 m_fastAckFailedTimeoutEvent (), |
| 252 m_ctsTimeoutEvent (), | 276 m_ctsTimeoutEvent (), |
| 253 m_sendCtsEvent (), | 277 m_sendCtsEvent (), |
| 254 m_sendAckEvent (), | 278 m_sendAckEvent (), |
| 255 m_sendDataEvent (), | 279 m_sendDataEvent (), |
| 256 m_waitSifsEvent (), | 280 m_waitSifsEvent (), |
| 257 m_currentPacket (0), | 281 m_currentPacket (0), |
| 258 m_listener (0) | 282 m_listener (0) |
| 259 { | 283 { |
| 260 NS_LOG_FUNCTION (this); | 284 NS_LOG_FUNCTION (this); |
| 261 m_lastNavDuration = Seconds (0); | 285 m_lastNavDuration = Seconds (0); |
| 262 m_lastNavStart = Seconds (0); | 286 m_lastNavStart = Seconds (0); |
| 263 } | 287 } |
| 264 | 288 |
| 265 MacLow::~MacLow () | 289 MacLow::~MacLow () |
| 266 { | 290 { |
| 267 NS_LOG_FUNCTION (this); | 291 NS_LOG_FUNCTION (this); |
| 268 } | 292 } |
| 269 | 293 |
| 270 void | 294 void |
| 295 MacLow::SetupPhyMacLowListener (Ptr<WifiPhy> phy) | |
| 296 { | |
| 297 m_phyMacLowListener = new PhyMacLowListener (this); | |
|
Mathieu Lacage
2009/08/19 08:19:12
delete in DoDispose ?
Ramon Bauza
2009/09/08 11:36:08
On 2009/08/19 08:19:12, Mathieu Lacage wrote:
> de
| |
| 298 phy->RegisterListener (m_phyMacLowListener); | |
| 299 } | |
| 300 | |
| 301 | |
| 302 void | |
| 271 MacLow::DoDispose (void) | 303 MacLow::DoDispose (void) |
| 272 { | 304 { |
| 273 NS_LOG_FUNCTION (this); | 305 NS_LOG_FUNCTION (this); |
| 274 CancelAllEvents (); | 306 CancelAllEvents (); |
| 275 m_phy = 0; | 307 m_phy = 0; |
| 276 m_stationManager = 0; | 308 m_stationManager = 0; |
| 277 } | 309 } |
| 278 | 310 |
| 279 void | 311 void |
| 280 MacLow::CancelAllEvents (void) | 312 MacLow::CancelAllEvents (void) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 332 m_listener = 0; | 364 m_listener = 0; |
| 333 } | 365 } |
| 334 } | 366 } |
| 335 | 367 |
| 336 void | 368 void |
| 337 MacLow::SetPhy (Ptr<WifiPhy> phy) | 369 MacLow::SetPhy (Ptr<WifiPhy> phy) |
| 338 { | 370 { |
| 339 m_phy = phy; | 371 m_phy = phy; |
| 340 m_phy->SetReceiveOkCallback (MakeCallback (&MacLow::ReceiveOk, this)); | 372 m_phy->SetReceiveOkCallback (MakeCallback (&MacLow::ReceiveOk, this)); |
| 341 m_phy->SetReceiveErrorCallback (MakeCallback (&MacLow::ReceiveError, this)); | 373 m_phy->SetReceiveErrorCallback (MakeCallback (&MacLow::ReceiveError, this)); |
| 374 SetupPhyMacLowListener(phy); | |
| 342 } | 375 } |
| 343 void | 376 void |
| 344 MacLow::SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> manager) | 377 MacLow::SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> manager) |
| 345 { | 378 { |
| 346 m_stationManager = manager; | 379 m_stationManager = manager; |
| 347 } | 380 } |
| 348 | 381 |
| 349 void | 382 void |
| 350 MacLow::SetAddress (Mac48Address ad) | 383 MacLow::SetAddress (Mac48Address ad) |
| 351 { | 384 { |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 482 if (m_txParams.MustWaitFastAck ()) | 515 if (m_txParams.MustWaitFastAck ()) |
| 483 { | 516 { |
| 484 NS_ASSERT (m_fastAckFailedTimeoutEvent.IsExpired ()); | 517 NS_ASSERT (m_fastAckFailedTimeoutEvent.IsExpired ()); |
| 485 m_fastAckFailedTimeoutEvent = Simulator::Schedule (GetSifs (), | 518 m_fastAckFailedTimeoutEvent = Simulator::Schedule (GetSifs (), |
| 486 &MacLow::FastAckFailedT imeout, this); | 519 &MacLow::FastAckFailedT imeout, this); |
| 487 } | 520 } |
| 488 return; | 521 return; |
| 489 } | 522 } |
| 490 | 523 |
| 491 void | 524 void |
| 525 MacLow::NotifySwitchingStartNow (Time duration) | |
| 526 { | |
| 527 NS_LOG_DEBUG ("switching channel. Cancelling MAC pending events"); | |
| 528 m_stationManager->Reset(); | |
| 529 CancelAllEvents(); | |
| 530 if (m_navCounterResetCtsMissed.IsRunning ()) | |
| 531 { | |
| 532 m_navCounterResetCtsMissed.Cancel(); | |
| 533 } | |
| 534 m_lastNavStart = Simulator::Now (); | |
| 535 m_lastNavDuration = Seconds (0); | |
| 536 m_currentPacket = 0; | |
| 537 m_listener = 0; | |
| 538 } | |
| 539 | |
| 540 void | |
| 492 MacLow::ReceiveOk (Ptr<Packet> packet, double rxSnr, WifiMode txMode, WifiPreamb le preamble) | 541 MacLow::ReceiveOk (Ptr<Packet> packet, double rxSnr, WifiMode txMode, WifiPreamb le preamble) |
| 493 { | 542 { |
| 494 NS_LOG_FUNCTION (this << packet << rxSnr << txMode << preamble); | 543 NS_LOG_FUNCTION (this << packet << rxSnr << txMode << preamble); |
| 495 /* A packet is received from the PHY. | 544 /* A packet is received from the PHY. |
| 496 * When we have handled this packet, | 545 * When we have handled this packet, |
| 497 * we handle any packet present in the | 546 * we handle any packet present in the |
| 498 * packet queue. | 547 * packet queue. |
| 499 */ | 548 */ |
| 500 WifiMacHeader hdr; | 549 WifiMacHeader hdr; |
| 501 packet->RemoveHeader (hdr); | 550 packet->RemoveHeader (hdr); |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1190 packet->AddTrailer (fcs); | 1239 packet->AddTrailer (fcs); |
| 1191 | 1240 |
| 1192 struct SnrTag tag; | 1241 struct SnrTag tag; |
| 1193 tag.Set (dataSnr); | 1242 tag.Set (dataSnr); |
| 1194 packet->AddPacketTag (tag); | 1243 packet->AddPacketTag (tag); |
| 1195 | 1244 |
| 1196 ForwardDown (packet, &ack, ackTxMode); | 1245 ForwardDown (packet, &ack, ackTxMode); |
| 1197 } | 1246 } |
| 1198 | 1247 |
| 1199 } // namespace ns3 | 1248 } // namespace ns3 |
| OLD | NEW |