src/wifi/model/ap-wifi-mac.cc
changeset 9705 43fa2408aa05
parent 9703 681f35b212ff
child 10139 17a71cd49da3
equal deleted inserted replaced
9704:1db7690f8e8f 9705:43fa2408aa05
    96 }
    96 }
    97 
    97 
    98 void
    98 void
    99 ApWifiMac::SetAddress (Mac48Address address)
    99 ApWifiMac::SetAddress (Mac48Address address)
   100 {
   100 {
       
   101   NS_LOG_FUNCTION (this << address);
   101   // As an AP, our MAC address is also the BSSID. Hence we are
   102   // As an AP, our MAC address is also the BSSID. Hence we are
   102   // overriding this function and setting both in our parent class.
   103   // overriding this function and setting both in our parent class.
   103   RegularWifiMac::SetAddress (address);
   104   RegularWifiMac::SetAddress (address);
   104   RegularWifiMac::SetBssid (address);
   105   RegularWifiMac::SetBssid (address);
   105 }
   106 }
   120 }
   121 }
   121 
   122 
   122 bool
   123 bool
   123 ApWifiMac::GetBeaconGeneration (void) const
   124 ApWifiMac::GetBeaconGeneration (void) const
   124 {
   125 {
       
   126   NS_LOG_FUNCTION (this);
   125   return m_enableBeaconGeneration;
   127   return m_enableBeaconGeneration;
   126 }
   128 }
   127 
   129 
   128 Time
   130 Time
   129 ApWifiMac::GetBeaconInterval (void) const
   131 ApWifiMac::GetBeaconInterval (void) const
   130 {
   132 {
       
   133   NS_LOG_FUNCTION (this);
   131   return m_beaconInterval;
   134   return m_beaconInterval;
   132 }
   135 }
   133 
   136 
   134 void
   137 void
   135 ApWifiMac::SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> stationManager)
   138 ApWifiMac::SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> stationManager)
   140 }
   143 }
   141 
   144 
   142 void
   145 void
   143 ApWifiMac::SetLinkUpCallback (Callback<void> linkUp)
   146 ApWifiMac::SetLinkUpCallback (Callback<void> linkUp)
   144 {
   147 {
   145   NS_LOG_FUNCTION (this);
   148   NS_LOG_FUNCTION (this << &linkUp);
   146   RegularWifiMac::SetLinkUpCallback (linkUp);
   149   RegularWifiMac::SetLinkUpCallback (linkUp);
   147 
   150 
   148   // The approach taken here is that, from the point of view of an AP,
   151   // The approach taken here is that, from the point of view of an AP,
   149   // the link is always up, so we immediately invoke the callback if
   152   // the link is always up, so we immediately invoke the callback if
   150   // one is set
   153   // one is set
   171 
   174 
   172 void
   175 void
   173 ApWifiMac::ForwardDown (Ptr<const Packet> packet, Mac48Address from,
   176 ApWifiMac::ForwardDown (Ptr<const Packet> packet, Mac48Address from,
   174                         Mac48Address to)
   177                         Mac48Address to)
   175 {
   178 {
       
   179   NS_LOG_FUNCTION (this << packet << from << to);
   176   // If we are not a QoS AP then we definitely want to use AC_BE to
   180   // If we are not a QoS AP then we definitely want to use AC_BE to
   177   // transmit the packet. A TID of zero will map to AC_BE (through \c
   181   // transmit the packet. A TID of zero will map to AC_BE (through \c
   178   // QosUtilsMapTidToAc()), so we use that as our default here.
   182   // QosUtilsMapTidToAc()), so we use that as our default here.
   179   uint8_t tid = 0;
   183   uint8_t tid = 0;
   180 
   184 
   196 
   200 
   197 void
   201 void
   198 ApWifiMac::ForwardDown (Ptr<const Packet> packet, Mac48Address from,
   202 ApWifiMac::ForwardDown (Ptr<const Packet> packet, Mac48Address from,
   199                         Mac48Address to, uint8_t tid)
   203                         Mac48Address to, uint8_t tid)
   200 {
   204 {
   201   NS_LOG_FUNCTION (this << packet << from << to);
   205   NS_LOG_FUNCTION (this << packet << from << to << static_cast<uint32_t> (tid));
   202   WifiMacHeader hdr;
   206   WifiMacHeader hdr;
   203 
   207 
   204   // For now, an AP that supports QoS does not support non-QoS
   208   // For now, an AP that supports QoS does not support non-QoS
   205   // associations, and vice versa. In future the AP model should
   209   // associations, and vice versa. In future the AP model should
   206   // support simultaneously associated QoS and non-QoS STAs, at which
   210   // support simultaneously associated QoS and non-QoS STAs, at which
   252 }
   256 }
   253 
   257 
   254 void
   258 void
   255 ApWifiMac::Enqueue (Ptr<const Packet> packet, Mac48Address to)
   259 ApWifiMac::Enqueue (Ptr<const Packet> packet, Mac48Address to)
   256 {
   260 {
       
   261   NS_LOG_FUNCTION (this << packet << to);
   257   // We're sending this packet with a from address that is our own. We
   262   // We're sending this packet with a from address that is our own. We
   258   // get that address from the lower MAC and make use of the
   263   // get that address from the lower MAC and make use of the
   259   // from-spoofing Enqueue() method to avoid duplicated code.
   264   // from-spoofing Enqueue() method to avoid duplicated code.
   260   Enqueue (packet, to, m_low->GetAddress ());
   265   Enqueue (packet, to, m_low->GetAddress ());
   261 }
   266 }
   262 
   267 
   263 bool
   268 bool
   264 ApWifiMac::SupportsSendFrom (void) const
   269 ApWifiMac::SupportsSendFrom (void) const
   265 {
   270 {
       
   271   NS_LOG_FUNCTION (this);
   266   return true;
   272   return true;
   267 }
   273 }
   268 
   274 
   269 SupportedRates
   275 SupportedRates
   270 ApWifiMac::GetSupportedRates (void) const
   276 ApWifiMac::GetSupportedRates (void) const
   271 {
   277 {
       
   278   NS_LOG_FUNCTION (this);
   272   // send the set of supported rates and make sure that we indicate
   279   // send the set of supported rates and make sure that we indicate
   273   // the Basic Rate set in this set of supported rates.
   280   // the Basic Rate set in this set of supported rates.
   274   SupportedRates rates;
   281   SupportedRates rates;
   275   for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
   282   for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
   276     {
   283     {
   540 
   547 
   541 void
   548 void
   542 ApWifiMac::DeaggregateAmsduAndForward (Ptr<Packet> aggregatedPacket,
   549 ApWifiMac::DeaggregateAmsduAndForward (Ptr<Packet> aggregatedPacket,
   543                                        const WifiMacHeader *hdr)
   550                                        const WifiMacHeader *hdr)
   544 {
   551 {
       
   552   NS_LOG_FUNCTION (this << aggregatedPacket << hdr);
   545   MsduAggregator::DeaggregatedMsdus packets =
   553   MsduAggregator::DeaggregatedMsdus packets =
   546     MsduAggregator::Deaggregate (aggregatedPacket);
   554     MsduAggregator::Deaggregate (aggregatedPacket);
   547 
   555 
   548   for (MsduAggregator::DeaggregatedMsdusCI i = packets.begin ();
   556   for (MsduAggregator::DeaggregatedMsdusCI i = packets.begin ();
   549        i != packets.end (); ++i)
   557        i != packets.end (); ++i)
   564 }
   572 }
   565 
   573 
   566 void
   574 void
   567 ApWifiMac::DoInitialize (void)
   575 ApWifiMac::DoInitialize (void)
   568 {
   576 {
       
   577   NS_LOG_FUNCTION (this);
   569   m_beaconDca->Initialize ();
   578   m_beaconDca->Initialize ();
   570   m_beaconEvent.Cancel ();
   579   m_beaconEvent.Cancel ();
   571   if (m_enableBeaconGeneration)
   580   if (m_enableBeaconGeneration)
   572     {
   581     {
   573       m_beaconEvent = Simulator::ScheduleNow (&ApWifiMac::SendOneBeacon, this);
   582       m_beaconEvent = Simulator::ScheduleNow (&ApWifiMac::SendOneBeacon, this);