1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 /* |
2 /* |
3 * Copyright (c) 2004,2005,2006 INRIA |
3 * Copyright (c) 2004,2005,2006 INRIA |
4 * |
4 * |
5 * This program is free software; you can redistribute it and/or modify |
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 |
6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; |
7 * published by the Free Software Foundation; |
8 * |
8 * |
9 * This program is distributed in the hope that it will be useful, |
9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
33 uint32_t m_timer; |
33 uint32_t m_timer; |
34 uint32_t m_success; |
34 uint32_t m_success; |
35 uint32_t m_failed; |
35 uint32_t m_failed; |
36 bool m_recovery; |
36 bool m_recovery; |
37 uint32_t m_retry; |
37 uint32_t m_retry; |
38 |
38 |
39 uint32_t m_timerTimeout; |
39 uint32_t m_timerTimeout; |
40 uint32_t m_successThreshold; |
40 uint32_t m_successThreshold; |
41 |
41 |
42 uint32_t m_rate; |
42 uint32_t m_rate; |
43 }; |
43 }; |
44 |
44 |
45 NS_OBJECT_ENSURE_REGISTERED (ArfWifiManager); |
45 NS_OBJECT_ENSURE_REGISTERED (ArfWifiManager); |
46 |
46 |
47 TypeId |
47 TypeId |
48 ArfWifiManager::GetTypeId (void) |
48 ArfWifiManager::GetTypeId (void) |
49 { |
49 { |
50 static TypeId tid = TypeId ("ns3::ArfWifiManager") |
50 static TypeId tid = TypeId ("ns3::ArfWifiManager") |
51 .SetParent<WifiRemoteStationManager> () |
51 .SetParent<WifiRemoteStationManager> () |
52 .AddConstructor<ArfWifiManager> () |
52 .AddConstructor<ArfWifiManager> () |
57 .AddAttribute ("SuccessThreshold", |
57 .AddAttribute ("SuccessThreshold", |
58 "The minimum number of sucessfull transmissions to try a new rate.", |
58 "The minimum number of sucessfull transmissions to try a new rate.", |
59 UintegerValue (10), |
59 UintegerValue (10), |
60 MakeUintegerAccessor (&ArfWifiManager::m_successThreshold), |
60 MakeUintegerAccessor (&ArfWifiManager::m_successThreshold), |
61 MakeUintegerChecker<uint32_t> ()) |
61 MakeUintegerChecker<uint32_t> ()) |
62 ; |
62 ; |
63 return tid; |
63 return tid; |
64 } |
64 } |
65 |
65 |
66 ArfWifiManager::ArfWifiManager () |
66 ArfWifiManager::ArfWifiManager () |
67 {} |
67 { |
|
68 } |
68 ArfWifiManager::~ArfWifiManager () |
69 ArfWifiManager::~ArfWifiManager () |
69 {} |
70 { |
|
71 } |
70 WifiRemoteStation * |
72 WifiRemoteStation * |
71 ArfWifiManager::DoCreateStation (void) const |
73 ArfWifiManager::DoCreateStation (void) const |
72 { |
74 { |
73 ArfWifiRemoteStation *station = new ArfWifiRemoteStation (); |
75 ArfWifiRemoteStation *station = new ArfWifiRemoteStation (); |
74 |
76 |
82 station->m_timer = 0; |
84 station->m_timer = 0; |
83 |
85 |
84 return station; |
86 return station; |
85 } |
87 } |
86 |
88 |
87 void |
89 void |
88 ArfWifiManager::DoReportRtsFailed (WifiRemoteStation *station) |
90 ArfWifiManager::DoReportRtsFailed (WifiRemoteStation *station) |
89 {} |
91 { |
|
92 } |
90 /** |
93 /** |
91 * It is important to realize that "recovery" mode starts after failure of |
94 * It is important to realize that "recovery" mode starts after failure of |
92 * the first transmission after a rate increase and ends at the first successful |
95 * the first transmission after a rate increase and ends at the first successful |
93 * transmission. Specifically, recovery mode transcends retransmissions boundaries. |
96 * transmission. Specifically, recovery mode transcends retransmissions boundaries. |
94 * Fundamentally, ARF handles each data transmission independently, whether it |
97 * Fundamentally, ARF handles each data transmission independently, whether it |
95 * is the initial transmission of a packet or the retransmission of a packet. |
98 * is the initial transmission of a packet or the retransmission of a packet. |
96 * The fundamental reason for this is that there is a backoff between each data |
99 * The fundamental reason for this is that there is a backoff between each data |
97 * transmission, be it an initial transmission or a retransmission. |
100 * transmission, be it an initial transmission or a retransmission. |
98 */ |
101 */ |
99 void |
102 void |
100 ArfWifiManager::DoReportDataFailed (WifiRemoteStation *st) |
103 ArfWifiManager::DoReportDataFailed (WifiRemoteStation *st) |
101 { |
104 { |
102 ArfWifiRemoteStation *station = (ArfWifiRemoteStation *)st; |
105 ArfWifiRemoteStation *station = (ArfWifiRemoteStation *)st; |
103 station->m_timer++; |
106 station->m_timer++; |
104 station->m_failed++; |
107 station->m_failed++; |
105 station->m_retry++; |
108 station->m_retry++; |
106 station->m_success = 0; |
109 station->m_success = 0; |
107 |
110 |
108 if (station->m_recovery) |
111 if (station->m_recovery) |
109 { |
112 { |
110 NS_ASSERT (station->m_retry >= 1); |
113 NS_ASSERT (station->m_retry >= 1); |
111 if (station->m_retry == 1) |
114 if (station->m_retry == 1) |
112 { |
115 { |
113 // need recovery fallback |
116 // need recovery fallback |
115 { |
118 { |
116 station->m_rate--; |
119 station->m_rate--; |
117 } |
120 } |
118 } |
121 } |
119 station->m_timer = 0; |
122 station->m_timer = 0; |
120 } |
123 } |
121 else |
124 else |
122 { |
125 { |
123 NS_ASSERT (station->m_retry >= 1); |
126 NS_ASSERT (station->m_retry >= 1); |
124 if (((station->m_retry - 1) % 2) == 1) |
127 if (((station->m_retry - 1) % 2) == 1) |
125 { |
128 { |
126 // need normal fallback |
129 // need normal fallback |
127 if (station->m_rate != 0) |
130 if (station->m_rate != 0) |
128 { |
131 { |
129 station->m_rate--; |
132 station->m_rate--; |
130 } |
133 } |
131 } |
134 } |
132 if (station->m_retry >= 2) |
135 if (station->m_retry >= 2) |
133 { |
136 { |
134 station->m_timer = 0; |
137 station->m_timer = 0; |
135 } |
138 } |
136 } |
139 } |
137 } |
140 } |
138 void |
141 void |
139 ArfWifiManager::DoReportRxOk (WifiRemoteStation *station, |
142 ArfWifiManager::DoReportRxOk (WifiRemoteStation *station, |
140 double rxSnr, WifiMode txMode) |
143 double rxSnr, WifiMode txMode) |
141 {} |
144 { |
|
145 } |
142 void ArfWifiManager::DoReportRtsOk (WifiRemoteStation *station, |
146 void ArfWifiManager::DoReportRtsOk (WifiRemoteStation *station, |
143 double ctsSnr, WifiMode ctsMode, double rtsSnr) |
147 double ctsSnr, WifiMode ctsMode, double rtsSnr) |
144 { |
148 { |
145 NS_LOG_DEBUG ("station="<<station<<" rts ok"); |
149 NS_LOG_DEBUG ("station=" << station << " rts ok"); |
146 } |
150 } |
147 void ArfWifiManager::DoReportDataOk (WifiRemoteStation *st, |
151 void ArfWifiManager::DoReportDataOk (WifiRemoteStation *st, |
148 double ackSnr, WifiMode ackMode, double dataSnr) |
152 double ackSnr, WifiMode ackMode, double dataSnr) |
149 { |
153 { |
150 ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st; |
154 ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st; |
152 station->m_success++; |
156 station->m_success++; |
153 station->m_failed = 0; |
157 station->m_failed = 0; |
154 station->m_recovery = false; |
158 station->m_recovery = false; |
155 station->m_retry = 0; |
159 station->m_retry = 0; |
156 NS_LOG_DEBUG ("station=" << station << " data ok success=" << station->m_success << ", timer=" << station->m_timer); |
160 NS_LOG_DEBUG ("station=" << station << " data ok success=" << station->m_success << ", timer=" << station->m_timer); |
157 if ((station->m_success == m_successThreshold || |
161 if ((station->m_success == m_successThreshold |
158 station->m_timer == m_timerThreshold) && |
162 || station->m_timer == m_timerThreshold) |
159 (station->m_rate < (station->m_state->m_operationalRateSet.size () - 1))) |
163 && (station->m_rate < (station->m_state->m_operationalRateSet.size () - 1))) |
160 { |
164 { |
161 NS_LOG_DEBUG ("station="<<station<<" inc rate"); |
165 NS_LOG_DEBUG ("station=" << station << " inc rate"); |
162 station->m_rate++; |
166 station->m_rate++; |
163 station->m_timer = 0; |
167 station->m_timer = 0; |
164 station->m_success = 0; |
168 station->m_success = 0; |
165 station->m_recovery = true; |
169 station->m_recovery = true; |
166 } |
170 } |
167 } |
171 } |
168 void |
172 void |
169 ArfWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *station) |
173 ArfWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *station) |
170 {} |
174 { |
171 void |
175 } |
|
176 void |
172 ArfWifiManager::DoReportFinalDataFailed (WifiRemoteStation *station) |
177 ArfWifiManager::DoReportFinalDataFailed (WifiRemoteStation *station) |
173 {} |
178 { |
|
179 } |
174 |
180 |
175 WifiMode |
181 WifiMode |
176 ArfWifiManager::DoGetDataMode (WifiRemoteStation *st, uint32_t size) |
182 ArfWifiManager::DoGetDataMode (WifiRemoteStation *st, uint32_t size) |
177 { |
183 { |
178 ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st; |
184 ArfWifiRemoteStation *station = (ArfWifiRemoteStation *) st; |