A Discrete-Event Network Simulator
API
mac-rx-middle.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005 INRIA
4  *
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
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 
21 #ifndef MAC_RX_MIDDLE_H
22 #define MAC_RX_MIDDLE_H
23 
24 #include <map>
25 #include <utility>
26 #include "ns3/callback.h"
27 #include "ns3/mac48-address.h"
28 #include "ns3/packet.h"
29 
30 namespace ns3 {
31 
32 class WifiMacHeader;
33 class OriginatorRxStatus;
34 
41 {
42 public:
47 
48  MacRxMiddle ();
49  ~MacRxMiddle ();
50 
56  void SetForwardCallback (ForwardUpCallback callback);
57 
58  void Receive (Ptr<Packet> packet, const WifiMacHeader *hdr);
59 private:
60  friend class MacRxMiddleTest;
79  bool IsDuplicate (const WifiMacHeader* hdr, OriginatorRxStatus *originator) const;
95  OriginatorRxStatus *originator);
96 
100  typedef std::map <Mac48Address, OriginatorRxStatus *, std::less<Mac48Address> > Originators;
104  typedef std::map <std::pair<Mac48Address, uint8_t>, OriginatorRxStatus *, std::less<std::pair<Mac48Address,uint8_t> > > QosOriginators;
108  typedef std::map <Mac48Address, OriginatorRxStatus *, std::less<Mac48Address> >::iterator OriginatorsI;
112  typedef std::map <std::pair<Mac48Address, uint8_t>, OriginatorRxStatus *, std::less<std::pair<Mac48Address,uint8_t> > >::iterator QosOriginatorsI;
113  Originators m_originatorStatus;
114  QosOriginators m_qosOriginatorStatus;
115  ForwardUpCallback m_callback;
116 };
117 
118 } // namespace ns3
119 
120 
121 #endif /* MAC_RX_MIDDLE_H */
Callback template class.
Definition: callback.h:984
std::map< std::pair< Mac48Address, uint8_t >, OriginatorRxStatus *, std::less< std::pair< Mac48Address, uint8_t > > > QosOriginators
typedef for a map between address, OriginatorRxStatus, and Traffic ID
void SetForwardCallback(ForwardUpCallback callback)
Set a callback to forward the packet up.
std::map< std::pair< Mac48Address, uint8_t >, OriginatorRxStatus *, std::less< std::pair< Mac48Address, uint8_t > > >::iterator QosOriginatorsI
typedef for an interator for QosOriginators
This class handles duplicate detection and recomposition of fragments.
Definition: mac-rx-middle.h:40
void Receive(Ptr< Packet > packet, const WifiMacHeader *hdr)
Ptr< Packet > HandleFragments(Ptr< Packet > packet, const WifiMacHeader *hdr, OriginatorRxStatus *originator)
Check if the received packet is a fragment and handle it appropriately.
std::map< Mac48Address, OriginatorRxStatus *, std::less< Mac48Address > >::iterator OriginatorsI
typedef for an interator for Originators
OriginatorRxStatus * Lookup(const WifiMacHeader *hdr)
Look up for OriginatorRxStatus associated with the sender address (by looking at ADDR2 field in the h...
Originators m_originatorStatus
bool IsDuplicate(const WifiMacHeader *hdr, OriginatorRxStatus *originator) const
Check if we have already received the packet from the sender before (by looking at the sequence contr...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::map< Mac48Address, OriginatorRxStatus *, std::less< Mac48Address > > Originators
typedef for a map between address and OriginatorRxStatus
Callback< void, Ptr< Packet >, const WifiMacHeader * > ForwardUpCallback
typedef for callback
Definition: mac-rx-middle.h:46
friend class MacRxMiddleTest
Definition: mac-rx-middle.h:60
ForwardUpCallback m_callback
A class to keep track of the packet originator status.
QosOriginators m_qosOriginatorStatus
Implements the IEEE 802.11 MAC header.