author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Fri, 10 Oct 2008 09:24:35 +0200 | |
changeset 3736 | 9819ffe46a68 |
parent 3604 | a84d99890289 |
child 3817 | 4ed410f69d36 |
permissions | -rw-r--r-- |
1933
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
2 |
/* |
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
3 |
* Copyright (c) 2005 INRIA |
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
4 |
* |
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
8 |
* |
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
13 |
* |
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
17 |
* |
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
18 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
*/ |
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
21 |
#include "adhoc-wifi-mac.h" |
1933
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
22 |
#include "dca-txop.h" |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
23 |
#include "mac-low.h" |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
24 |
#include "mac-rx-middle.h" |
2003
335dc094e52a
support BRAND_NEW station in adhoc code. initialize the supported rates.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1970
diff
changeset
|
25 |
#include "wifi-phy.h" |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
26 |
#include "dcf-manager.h" |
1933
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
27 |
#include "ns3/packet.h" |
1970
df11f51cd342
convert tracing to log system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
28 |
#include "ns3/log.h" |
1933
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
29 |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
30 |
NS_LOG_COMPONENT_DEFINE ("AdhocWifiMac"); |
1933
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
31 |
|
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
32 |
namespace ns3 { |
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
33 |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
34 |
NS_OBJECT_ENSURE_REGISTERED (AdhocWifiMac); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
35 |
|
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
36 |
TypeId |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
37 |
AdhocWifiMac::GetTypeId (void) |
2054
ba8e810bae4c
derive WifiPhy from Object and manage it with a Ptr<>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2006
diff
changeset
|
38 |
{ |
2602
d9262bff6df2
add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2592
diff
changeset
|
39 |
static TypeId tid = TypeId ("ns3::AdhocWifiMac") |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
40 |
.SetParent<WifiMac> () |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
41 |
.AddConstructor<AdhocWifiMac> () |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
42 |
; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
43 |
return tid; |
2054
ba8e810bae4c
derive WifiPhy from Object and manage it with a Ptr<>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2006
diff
changeset
|
44 |
} |
1933
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
45 |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
46 |
AdhocWifiMac::AdhocWifiMac () |
1933
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
47 |
{ |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
48 |
m_rxMiddle = new MacRxMiddle (); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
49 |
m_rxMiddle->SetForwardCallback (MakeCallback (&AdhocWifiMac::ForwardUp, this)); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
50 |
|
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2530
diff
changeset
|
51 |
m_low = CreateObject<MacLow> (); |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
52 |
m_low->SetRxCallback (MakeCallback (&MacRxMiddle::Receive, m_rxMiddle)); |
3600
5888dfe3f245
move GetBssid down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3599
diff
changeset
|
53 |
m_low->SetBssid (GetBssid ()); |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
54 |
|
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
55 |
m_dcfManager = new DcfManager (); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
56 |
m_dcfManager->SetupLowListener (m_low); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
57 |
|
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
58 |
m_dca = CreateObject<DcaTxop> (); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
59 |
m_dca->SetLow (m_low); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
60 |
m_dca->SetManager (m_dcfManager); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
61 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
62 |
AdhocWifiMac::~AdhocWifiMac () |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
63 |
{} |
1933
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
64 |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
65 |
void |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
66 |
AdhocWifiMac::DoDispose (void) |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
67 |
{ |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
68 |
delete m_rxMiddle; |
2528
a527ec47b756
avoid crashing AP wifi sample
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2524
diff
changeset
|
69 |
delete m_dcfManager; |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
70 |
m_rxMiddle = 0; |
2530
05f9cec44621
avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2528
diff
changeset
|
71 |
m_dcfManager = 0; |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
72 |
m_low = 0; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
73 |
m_phy = 0; |
2530
05f9cec44621
avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2528
diff
changeset
|
74 |
m_dca = 0; |
05f9cec44621
avoid memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2528
diff
changeset
|
75 |
m_stationManager = 0; |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
76 |
WifiMac::DoDispose (); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
77 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
78 |
|
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
79 |
void |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
80 |
AdhocWifiMac::SetSlot (Time slotTime) |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
81 |
{ |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
82 |
m_dcfManager->SetSlot (slotTime); |
3599
721bd46c15f8
move slot and pifs down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3598
diff
changeset
|
83 |
m_low->SetSlotTime (slotTime); |
1933
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
84 |
} |
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
85 |
void |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
86 |
AdhocWifiMac::SetSifs (Time sifs) |
1933
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
87 |
{ |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
88 |
m_dcfManager->SetSifs (sifs); |
3598
7b209b3b6af2
move sifs down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3597
diff
changeset
|
89 |
m_low->SetSifs (sifs); |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
90 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
91 |
void |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
92 |
AdhocWifiMac::SetEifsNoDifs (Time eifsNoDifs) |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
93 |
{ |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
94 |
m_dcfManager->SetEifsNoDifs (eifsNoDifs); |
2686 | 95 |
m_eifsNoDifs = eifsNoDifs; |
96 |
} |
|
3596
6c39b712a535
move Address and ack timeout down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3517
diff
changeset
|
97 |
void |
6c39b712a535
move Address and ack timeout down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3517
diff
changeset
|
98 |
AdhocWifiMac::SetAckTimeout (Time ackTimeout) |
6c39b712a535
move Address and ack timeout down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3517
diff
changeset
|
99 |
{ |
6c39b712a535
move Address and ack timeout down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3517
diff
changeset
|
100 |
m_low->SetAckTimeout (ackTimeout); |
6c39b712a535
move Address and ack timeout down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3517
diff
changeset
|
101 |
} |
3597
fe35e5be4b78
move cts timeout down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3596
diff
changeset
|
102 |
void |
fe35e5be4b78
move cts timeout down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3596
diff
changeset
|
103 |
AdhocWifiMac::SetCtsTimeout (Time ctsTimeout) |
fe35e5be4b78
move cts timeout down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3596
diff
changeset
|
104 |
{ |
fe35e5be4b78
move cts timeout down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3596
diff
changeset
|
105 |
m_low->SetCtsTimeout (ctsTimeout); |
fe35e5be4b78
move cts timeout down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3596
diff
changeset
|
106 |
} |
3599
721bd46c15f8
move slot and pifs down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3598
diff
changeset
|
107 |
void |
721bd46c15f8
move slot and pifs down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3598
diff
changeset
|
108 |
AdhocWifiMac::SetPifs (Time pifs) |
721bd46c15f8
move slot and pifs down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3598
diff
changeset
|
109 |
{ |
721bd46c15f8
move slot and pifs down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3598
diff
changeset
|
110 |
m_low->SetPifs (pifs); |
721bd46c15f8
move slot and pifs down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3598
diff
changeset
|
111 |
} |
2686 | 112 |
Time |
113 |
AdhocWifiMac::GetSlot (void) const |
|
114 |
{ |
|
3599
721bd46c15f8
move slot and pifs down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3598
diff
changeset
|
115 |
return m_low->GetSlotTime (); |
2686 | 116 |
} |
117 |
Time |
|
118 |
AdhocWifiMac::GetSifs (void) const |
|
119 |
{ |
|
3598
7b209b3b6af2
move sifs down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3597
diff
changeset
|
120 |
return m_low->GetSifs (); |
2686 | 121 |
} |
122 |
Time |
|
123 |
AdhocWifiMac::GetEifsNoDifs (void) const |
|
124 |
{ |
|
125 |
return m_eifsNoDifs; |
|
1933
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
126 |
} |
3596
6c39b712a535
move Address and ack timeout down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3517
diff
changeset
|
127 |
Time |
6c39b712a535
move Address and ack timeout down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3517
diff
changeset
|
128 |
AdhocWifiMac::GetAckTimeout (void) const |
6c39b712a535
move Address and ack timeout down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3517
diff
changeset
|
129 |
{ |
6c39b712a535
move Address and ack timeout down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3517
diff
changeset
|
130 |
return m_low->GetAckTimeout (); |
6c39b712a535
move Address and ack timeout down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3517
diff
changeset
|
131 |
} |
3597
fe35e5be4b78
move cts timeout down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3596
diff
changeset
|
132 |
Time |
fe35e5be4b78
move cts timeout down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3596
diff
changeset
|
133 |
AdhocWifiMac::GetCtsTimeout (void) const |
fe35e5be4b78
move cts timeout down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3596
diff
changeset
|
134 |
{ |
fe35e5be4b78
move cts timeout down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3596
diff
changeset
|
135 |
return m_low->GetCtsTimeout (); |
fe35e5be4b78
move cts timeout down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3596
diff
changeset
|
136 |
} |
3599
721bd46c15f8
move slot and pifs down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3598
diff
changeset
|
137 |
Time |
721bd46c15f8
move slot and pifs down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3598
diff
changeset
|
138 |
AdhocWifiMac::GetPifs (void) const |
721bd46c15f8
move slot and pifs down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3598
diff
changeset
|
139 |
{ |
721bd46c15f8
move slot and pifs down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3598
diff
changeset
|
140 |
return m_low->GetPifs (); |
721bd46c15f8
move slot and pifs down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3598
diff
changeset
|
141 |
} |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
142 |
void |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
143 |
AdhocWifiMac::SetWifiPhy (Ptr<WifiPhy> phy) |
1933
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
144 |
{ |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
145 |
m_phy = phy; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
146 |
m_dcfManager->SetupPhyListener (phy); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
147 |
m_low->SetPhy (phy); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
148 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
149 |
void |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
150 |
AdhocWifiMac::SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> stationManager) |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
151 |
{ |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
152 |
m_stationManager = stationManager; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
153 |
m_dca->SetWifiRemoteStationManager (stationManager); |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
154 |
m_low->SetWifiRemoteStationManager (stationManager); |
1933
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
155 |
} |
2003
335dc094e52a
support BRAND_NEW station in adhoc code. initialize the supported rates.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1970
diff
changeset
|
156 |
void |
3604
a84d99890289
implement promisc mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3603
diff
changeset
|
157 |
AdhocWifiMac::SetForwardUpCallback (Callback<void,Ptr<Packet>, Mac48Address, Mac48Address> upCallback) |
2003
335dc094e52a
support BRAND_NEW station in adhoc code. initialize the supported rates.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1970
diff
changeset
|
158 |
{ |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
159 |
m_upCallback = upCallback; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
160 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
161 |
void |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
162 |
AdhocWifiMac::SetLinkUpCallback (Callback<void> linkUp) |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
163 |
{ |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
164 |
// an Adhoc network is always UP. |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
165 |
linkUp (); |
2003
335dc094e52a
support BRAND_NEW station in adhoc code. initialize the supported rates.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1970
diff
changeset
|
166 |
} |
335dc094e52a
support BRAND_NEW station in adhoc code. initialize the supported rates.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1970
diff
changeset
|
167 |
void |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
168 |
AdhocWifiMac::SetLinkDownCallback (Callback<void> linkDown) |
3212
0c00342d6a73
improve attribute documentation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2686
diff
changeset
|
169 |
{} |
1933
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
170 |
Mac48Address |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
171 |
AdhocWifiMac::GetAddress (void) const |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
172 |
{ |
3596
6c39b712a535
move Address and ack timeout down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3517
diff
changeset
|
173 |
return m_low->GetAddress (); |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
174 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
175 |
Ssid |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
176 |
AdhocWifiMac::GetSsid (void) const |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
177 |
{ |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
178 |
return m_ssid; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
179 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
180 |
Mac48Address |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
181 |
AdhocWifiMac::GetBssid (void) const |
1933
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
182 |
{ |
3736
9819ffe46a68
bug 361: make GetBssid public.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3604
diff
changeset
|
183 |
return m_low->GetBssid (); |
1933
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
184 |
} |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
185 |
void |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
186 |
AdhocWifiMac::SetAddress (Mac48Address address) |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
187 |
{ |
3596
6c39b712a535
move Address and ack timeout down to MacLow
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3517
diff
changeset
|
188 |
m_low->SetAddress (address); |
3736
9819ffe46a68
bug 361: make GetBssid public.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3604
diff
changeset
|
189 |
m_low->SetBssid (address); |
9819ffe46a68
bug 361: make GetBssid public.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3604
diff
changeset
|
190 |
// XXX the bssid should be generated by the procedure |
9819ffe46a68
bug 361: make GetBssid public.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3604
diff
changeset
|
191 |
// described in ieee802.11 section 11.1.3 |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
192 |
} |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
193 |
void |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
194 |
AdhocWifiMac::SetSsid (Ssid ssid) |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
195 |
{ |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
196 |
// XXX: here, we should start a special adhoc network |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
197 |
m_ssid = ssid; |
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
198 |
} |
1933
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
199 |
|
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
200 |
void |
3517
5ba130a7f519
implement WifiNetDevice::SendFrom
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3212
diff
changeset
|
201 |
AdhocWifiMac::Enqueue (Ptr<const Packet> packet, Mac48Address to, Mac48Address from) |
1933
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
202 |
{ |
3602
e8e41feee205
implement SendFrom correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3600
diff
changeset
|
203 |
NS_FATAL_ERROR ("Adhoc does not support a from != m_low->GetAddress ()"); |
e8e41feee205
implement SendFrom correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3600
diff
changeset
|
204 |
} |
e8e41feee205
implement SendFrom correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3600
diff
changeset
|
205 |
void |
e8e41feee205
implement SendFrom correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3600
diff
changeset
|
206 |
AdhocWifiMac::Enqueue (Ptr<const Packet> packet, Mac48Address to) |
e8e41feee205
implement SendFrom correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3600
diff
changeset
|
207 |
{ |
e8e41feee205
implement SendFrom correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3600
diff
changeset
|
208 |
NS_LOG_FUNCTION (packet->GetSize () << to); |
1933
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
209 |
WifiMacHeader hdr; |
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
210 |
hdr.SetType (WIFI_MAC_DATA); |
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
211 |
hdr.SetAddr1 (to); |
3602
e8e41feee205
implement SendFrom correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3600
diff
changeset
|
212 |
hdr.SetAddr2 (m_low->GetAddress ()); |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
213 |
hdr.SetAddr3 (GetBssid ()); |
1933
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
214 |
hdr.SetDsNotFrom (); |
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
215 |
hdr.SetDsNotTo (); |
2003
335dc094e52a
support BRAND_NEW station in adhoc code. initialize the supported rates.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1970
diff
changeset
|
216 |
|
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
217 |
WifiRemoteStation *destination = m_stationManager->Lookup (to); |
2003
335dc094e52a
support BRAND_NEW station in adhoc code. initialize the supported rates.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1970
diff
changeset
|
218 |
if (destination->IsBrandNew ()) |
335dc094e52a
support BRAND_NEW station in adhoc code. initialize the supported rates.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1970
diff
changeset
|
219 |
{ |
335dc094e52a
support BRAND_NEW station in adhoc code. initialize the supported rates.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1970
diff
changeset
|
220 |
// in adhoc mode, we assume that every destination |
335dc094e52a
support BRAND_NEW station in adhoc code. initialize the supported rates.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1970
diff
changeset
|
221 |
// supports all the rates we support. |
335dc094e52a
support BRAND_NEW station in adhoc code. initialize the supported rates.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1970
diff
changeset
|
222 |
for (uint32_t i = 0; i < m_phy->GetNModes (); i++) |
335dc094e52a
support BRAND_NEW station in adhoc code. initialize the supported rates.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1970
diff
changeset
|
223 |
{ |
2006
6bb048d50235
make sure we record all needed supported modes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2003
diff
changeset
|
224 |
destination->AddSupportedMode (m_phy->GetMode (i)); |
2003
335dc094e52a
support BRAND_NEW station in adhoc code. initialize the supported rates.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1970
diff
changeset
|
225 |
} |
2006
6bb048d50235
make sure we record all needed supported modes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2003
diff
changeset
|
226 |
destination->RecordDisassociated (); |
2003
335dc094e52a
support BRAND_NEW station in adhoc code. initialize the supported rates.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1970
diff
changeset
|
227 |
} |
335dc094e52a
support BRAND_NEW station in adhoc code. initialize the supported rates.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1970
diff
changeset
|
228 |
|
1933
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
229 |
m_dca->Queue (packet, hdr); |
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
230 |
} |
3603
da21b3e410b6
implement SupportsSendFrom
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3602
diff
changeset
|
231 |
bool |
da21b3e410b6
implement SupportsSendFrom
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3602
diff
changeset
|
232 |
AdhocWifiMac::SupportsSendFrom (void) const |
da21b3e410b6
implement SupportsSendFrom
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3602
diff
changeset
|
233 |
{ |
da21b3e410b6
implement SupportsSendFrom
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3602
diff
changeset
|
234 |
return true; |
da21b3e410b6
implement SupportsSendFrom
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3602
diff
changeset
|
235 |
} |
1933
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
236 |
|
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
237 |
void |
2524
db72c0e7743e
port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2350
diff
changeset
|
238 |
AdhocWifiMac::ForwardUp (Ptr<Packet> packet, WifiMacHeader const *hdr) |
1933
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
239 |
{ |
2159
20f882e85b4a
port to Ptr<Packet> branch
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2054
diff
changeset
|
240 |
NS_LOG_DEBUG ("received size="<<packet->GetSize ()<<", from="<<hdr->GetAddr2 ()); |
3604
a84d99890289
implement promisc mode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
3603
diff
changeset
|
241 |
m_upCallback (packet, hdr->GetAddr2 (), hdr->GetAddr1 ()); |
1933
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
242 |
} |
59328b2e04e1
add MacHighAdhoc to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
243 |
|
1934
13c65460caee
fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1933
diff
changeset
|
244 |
} // namespace ns3 |