A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
uan-mac-aloha.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 University of Washington
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Leonard Tracy <lentracy@gmail.com>
7 */
8
9#ifndef UAN_MAC_ALOHA_H
10#define UAN_MAC_ALOHA_H
11
12#include "uan-mac.h"
13
14#include "ns3/mac8-address.h"
15
16namespace ns3
17{
18
19class UanPhy;
20class UanTxMode;
21
22/**
23 * \ingroup uan
24 *
25 * ALOHA MAC Protocol, the simplest MAC protocol for wireless networks.
26 *
27 * Packets enqueued are immediately transmitted. This MAC attaches
28 * a UanHeaderCommon to outgoing packets for address information.
29 * (The type field is not used)
30 */
31class UanMacAloha : public UanMac
32{
33 public:
34 /** Default constructor */
36 /** Dummy destructor, see DoDispose. */
37 ~UanMacAloha() override;
38 /**
39 * Register this type.
40 * \return The TypeId.
41 */
42 static TypeId GetTypeId();
43
44 // Inherited methods
45 bool Enqueue(Ptr<Packet> pkt, uint16_t protocolNumber, const Address& dest) override;
46 void SetForwardUpCb(Callback<void, Ptr<Packet>, uint16_t, const Mac8Address&> cb) override;
47 void AttachPhy(Ptr<UanPhy> phy) override;
48 void Clear() override;
49 int64_t AssignStreams(int64_t stream) override;
50
51 private:
52 /** PHY layer attached to this MAC. */
54 /** Forwarding up callback. */
56 /** Flag when we've been cleared. */
58
59 /**
60 * Receive packet from lower layer (passed to PHY as callback).
61 *
62 * \param pkt Packet being received.
63 * \param sinr SINR of received packet.
64 * \param txMode Mode of received packet.
65 */
66 void RxPacketGood(Ptr<Packet> pkt, double sinr, UanTxMode txMode);
67
68 /**
69 * Packet received at lower layer in error.
70 *
71 * \param pkt Packet received in error.
72 * \param sinr SINR of received packet.
73 */
74 void RxPacketError(Ptr<Packet> pkt, double sinr);
75
76 protected:
77 void DoDispose() override;
78
79}; // class UanMacAloha
80
81} // namespace ns3
82
83#endif /* UAN_MAC_ALOHA_H */
a polymophic address class
Definition address.h:90
Callback template class.
Definition callback.h:422
A class used for addressing MAC8 MAC's.
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
Definition type-id.h:48
ALOHA MAC Protocol, the simplest MAC protocol for wireless networks.
static TypeId GetTypeId()
Register this type.
Ptr< UanPhy > m_phy
PHY layer attached to this MAC.
void DoDispose() override
Destructor implementation.
bool m_cleared
Flag when we've been cleared.
bool Enqueue(Ptr< Packet > pkt, uint16_t protocolNumber, const Address &dest) override
Enqueue packet to be transmitted.
UanMacAloha()
Default constructor.
void AttachPhy(Ptr< UanPhy > phy) override
Attach PHY layer to this MAC.
void SetForwardUpCb(Callback< void, Ptr< Packet >, uint16_t, const Mac8Address & > cb) override
Set the callback to forward packets up to higher layers.
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
Callback< void, Ptr< Packet >, uint16_t, const Mac8Address & > m_forUpCb
Forwarding up callback.
void RxPacketGood(Ptr< Packet > pkt, double sinr, UanTxMode txMode)
Receive packet from lower layer (passed to PHY as callback).
~UanMacAloha() override
Dummy destructor, see DoDispose.
void RxPacketError(Ptr< Packet > pkt, double sinr)
Packet received at lower layer in error.
void Clear() override
Clears all pointer references.
Virtual base class for all UAN MAC protocols.
Definition uan-mac.h:35
Abstraction of packet modulation information.
Definition uan-tx-mode.h:32
Every class exported by the ns3 library is enclosed in the ns3 namespace.