00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "wifi-mac.h"
00021 #include "ns3/uinteger.h"
00022
00023 namespace ns3 {
00024
00025 NS_OBJECT_ENSURE_REGISTERED (WifiMac);
00026
00027 Time
00028 WifiMac::GetDefaultMaxPropagationDelay (void)
00029 {
00030
00031 return Seconds (1000.0 / 300000000.0);
00032 }
00033 Time
00034 WifiMac::GetDefaultSlot (void)
00035 {
00036
00037 return MicroSeconds (9);
00038 }
00039 Time
00040 WifiMac::GetDefaultSifs (void)
00041 {
00042
00043 return MicroSeconds (16);
00044 }
00045 Time
00046 WifiMac::GetDefaultEifsNoDifs (void)
00047 {
00048 return GetDefaultSifs () + GetDefaultCtsAckDelay ();
00049 }
00050 Time
00051 WifiMac::GetDefaultCtsAckDelay (void)
00052 {
00053
00054 return MicroSeconds (44);
00055 }
00056 Time
00057 WifiMac::GetDefaultCtsAckTimeout (void)
00058 {
00059
00060
00061
00062
00063 Time ctsTimeout = GetDefaultSifs ();
00064 ctsTimeout += GetDefaultCtsAckDelay ();
00065 ctsTimeout += GetDefaultMaxPropagationDelay () * Scalar (2);
00066 ctsTimeout += GetDefaultSlot ();
00067 return ctsTimeout;
00068 }
00069
00070
00071 TypeId
00072 WifiMac::GetTypeId (void)
00073 {
00074 static TypeId tid = TypeId ("ns3::WifiMac")
00075 .SetParent<Object> ()
00076 .AddAttribute ("CtsTimeout", "When this timeout expires, the RTS/CTS handshake has failed.",
00077 TimeValue (GetDefaultCtsAckTimeout ()),
00078 MakeTimeAccessor (&WifiMac::SetCtsTimeout,
00079 &WifiMac::GetCtsTimeout),
00080 MakeTimeChecker ())
00081 .AddAttribute ("AckTimeout", "When this timeout expires, the DATA/ACK handshake has failed.",
00082 TimeValue (GetDefaultCtsAckTimeout ()),
00083 MakeTimeAccessor (&WifiMac::GetAckTimeout,
00084 &WifiMac::SetAckTimeout),
00085 MakeTimeChecker ())
00086 .AddAttribute ("Sifs", "The value of the SIFS constant.",
00087 TimeValue (GetDefaultSifs ()),
00088 MakeTimeAccessor (&WifiMac::SetSifs,
00089 &WifiMac::GetSifs),
00090 MakeTimeChecker ())
00091 .AddAttribute ("EifsNoDifs", "The value of EIFS-DIFS",
00092 TimeValue (GetDefaultEifsNoDifs ()),
00093 MakeTimeAccessor (&WifiMac::SetEifsNoDifs,
00094 &WifiMac::GetEifsNoDifs),
00095 MakeTimeChecker ())
00096 .AddAttribute ("Slot", "The duration of a Slot.",
00097 TimeValue (GetDefaultSlot ()),
00098 MakeTimeAccessor (&WifiMac::SetSlot,
00099 &WifiMac::GetSlot),
00100 MakeTimeChecker ())
00101 .AddAttribute ("Pifs", "The value of the PIFS constant.",
00102 TimeValue (GetDefaultSifs () + GetDefaultSlot ()),
00103 MakeTimeAccessor (&WifiMac::SetPifs,
00104 &WifiMac::GetPifs),
00105 MakeTimeChecker ())
00106 .AddAttribute ("MaxPropagationDelay", "The maximum propagation delay. Unused for now.",
00107 TimeValue (GetDefaultMaxPropagationDelay ()),
00108 MakeTimeAccessor (&WifiMac::m_maxPropagationDelay),
00109 MakeTimeChecker ())
00110 .AddAttribute ("MaxMsduSize", "The maximum size of an MSDU accepted by the MAC layer."
00111 "This value conforms to the specification.",
00112 UintegerValue (2304),
00113 MakeUintegerAccessor (&WifiMac::m_maxMsduSize),
00114 MakeUintegerChecker<uint16_t> (1,2304))
00115 .AddAttribute ("Ssid", "The ssid we want to belong to.",
00116 SsidValue (Ssid ("default")),
00117 MakeSsidAccessor (&WifiMac::GetSsid,
00118 &WifiMac::SetSsid),
00119 MakeSsidChecker ())
00120 ;
00121 return tid;
00122 }
00123
00124 void
00125 WifiMac::SetMaxPropagationDelay (Time delay)
00126 {
00127 m_maxPropagationDelay = delay;
00128 }
00129
00130 Time
00131 WifiMac::GetMsduLifetime (void) const
00132 {
00133 return Seconds (10);
00134 }
00135 Time
00136 WifiMac::GetMaxPropagationDelay (void) const
00137 {
00138 return m_maxPropagationDelay;
00139 }
00140
00141 uint32_t
00142 WifiMac::GetMaxMsduSize (void) const
00143 {
00144 return m_maxMsduSize;
00145 }
00146
00147
00148 }