LEFT | RIGHT |
(no file at all) | |
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) 2007 Emmanuelle Laprise | 3 * Copyright (c) 2007 Emmanuelle Laprise |
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 |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "ns3/ethernet-trailer.h" | 25 #include "ns3/ethernet-trailer.h" |
26 #include "ns3/llc-snap-header.h" | 26 #include "ns3/llc-snap-header.h" |
27 #include "ns3/error-model.h" | 27 #include "ns3/error-model.h" |
28 #include "ns3/enum.h" | 28 #include "ns3/enum.h" |
29 #include "ns3/boolean.h" | 29 #include "ns3/boolean.h" |
30 #include "ns3/uinteger.h" | 30 #include "ns3/uinteger.h" |
31 #include "ns3/pointer.h" | 31 #include "ns3/pointer.h" |
32 #include "ns3/trace-source-accessor.h" | 32 #include "ns3/trace-source-accessor.h" |
33 #include "csma-net-device.h" | 33 #include "csma-net-device.h" |
34 #include "csma-channel.h" | 34 #include "csma-channel.h" |
| 35 #include "ns3/net-device-queue-interface.h" |
35 | 36 |
36 namespace ns3 { | 37 namespace ns3 { |
37 | 38 |
38 NS_LOG_COMPONENT_DEFINE ("CsmaNetDevice"); | 39 NS_LOG_COMPONENT_DEFINE ("CsmaNetDevice"); |
39 | 40 |
40 NS_OBJECT_ENSURE_REGISTERED (CsmaNetDevice); | 41 NS_OBJECT_ENSURE_REGISTERED (CsmaNetDevice); |
41 | 42 |
42 TypeId | 43 TypeId |
43 CsmaNetDevice::GetTypeId (void) | 44 CsmaNetDevice::GetTypeId (void) |
44 { | 45 { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 ; | 183 ; |
183 return tid; | 184 return tid; |
184 } | 185 } |
185 | 186 |
186 CsmaNetDevice::CsmaNetDevice () | 187 CsmaNetDevice::CsmaNetDevice () |
187 : m_linkUp (false) | 188 : m_linkUp (false) |
188 { | 189 { |
189 NS_LOG_FUNCTION (this); | 190 NS_LOG_FUNCTION (this); |
190 m_txMachineState = READY; | 191 m_txMachineState = READY; |
191 m_tInterframeGap = Seconds (0); | 192 m_tInterframeGap = Seconds (0); |
192 m_channel = 0; | 193 m_channel = 0; |
193 | 194 |
194 //· | 195 //· |
195 // We would like to let the attribute system take care of initializing the· | 196 // We would like to let the attribute system take care of initializing the· |
196 // packet encapsulation stuff, but we also don't want to get caught up in | 197 // packet encapsulation stuff, but we also don't want to get caught up in |
197 // initialization order changes. So we'll get the three problem variables | 198 // initialization order changes. So we'll get the three problem variables |
198 // into a consistent state here before the attribute calls, and then depend | 199 // into a consistent state here before the attribute calls, and then depend |
199 // on the semantics of the setters to preserve a consistent state. This· | 200 // on the semantics of the setters to preserve a consistent state. This· |
200 // really doesn't have to be the same set of values as the initial values· | 201 // really doesn't have to be the same set of values as the initial values· |
201 // set by the attributes, but it does have to be a consistent set. That is, | 202 // set by the attributes, but it does have to be a consistent set. That is, |
202 // you can just change the default encapsulation mode above without having· | 203 // you can just change the default encapsulation mode above without having· |
203 // to change it here. | 204 // to change it here. |
204 // | 205 // |
205 m_encapMode = DIX; | 206 m_encapMode = DIX; |
206 } | 207 } |
207 | 208 |
208 CsmaNetDevice::~CsmaNetDevice() | 209 CsmaNetDevice::~CsmaNetDevice() |
209 { | 210 { |
210 NS_LOG_FUNCTION_NOARGS (); | 211 NS_LOG_FUNCTION_NOARGS (); |
211 m_queue = 0; | 212 m_queue = 0; |
212 } | 213 } |
213 | 214 |
214 void | 215 void |
215 CsmaNetDevice::DoDispose () | 216 CsmaNetDevice::DoDispose () |
216 { | 217 { |
217 NS_LOG_FUNCTION_NOARGS (); | 218 NS_LOG_FUNCTION_NOARGS (); |
218 m_channel = 0; | 219 m_channel = 0; |
219 m_node = 0; | 220 m_node = 0; |
| 221 m_queue = 0; |
| 222 m_queueInterface = 0; |
220 NetDevice::DoDispose (); | 223 NetDevice::DoDispose (); |
| 224 } |
| 225 |
| 226 void |
| 227 CsmaNetDevice::DoInitialize (void) |
| 228 { |
| 229 if (m_queueInterface) |
| 230 { |
| 231 // create the transmission queue in case it has not been created yet (by |
| 232 // TrafficControlLayer::DoInitialize) |
| 233 if (m_queueInterface->GetNTxQueues () == 0) |
| 234 { |
| 235 m_queueInterface->CreateTxQueues (); |
| 236 } |
| 237 |
| 238 NS_ASSERT_MSG (m_queue != 0, "A Queue object has not been attached to the
device"); |
| 239 |
| 240 // connect the traced callbacks of m_queue to the static methods provided
by |
| 241 // the NetDeviceQueue class to support flow control and dynamic queue limi
ts. |
| 242 // This could not be done in NotifyNewAggregate because at that time we ar
e |
| 243 // not guaranteed that a queue has been attached to the netdevice |
| 244 m_queueInterface->ConnectQueueTraces (m_queue, 0); |
| 245 } |
| 246 |
| 247 NetDevice::DoInitialize (); |
| 248 } |
| 249 |
| 250 void |
| 251 CsmaNetDevice::NotifyNewAggregate (void) |
| 252 { |
| 253 NS_LOG_FUNCTION (this); |
| 254 if (m_queueInterface == 0) |
| 255 { |
| 256 Ptr<NetDeviceQueueInterface> ndqi = this->GetObject<NetDeviceQueueInterfac
e> (); |
| 257 //verify that it's a valid netdevice queue interface and that |
| 258 //the netdevice queue interface was not set before |
| 259 if (ndqi != 0) |
| 260 { |
| 261 m_queueInterface = ndqi; |
| 262 } |
| 263 } |
| 264 NetDevice::NotifyNewAggregate (); |
221 } | 265 } |
222 | 266 |
223 void | 267 void |
224 CsmaNetDevice::SetEncapsulationMode (enum EncapsulationMode mode) | 268 CsmaNetDevice::SetEncapsulationMode (enum EncapsulationMode mode) |
225 { | 269 { |
226 NS_LOG_FUNCTION (mode); | 270 NS_LOG_FUNCTION (mode); |
227 | 271 |
228 m_encapMode = mode; | 272 m_encapMode = mode; |
229 | 273 |
230 NS_LOG_LOGIC ("m_encapMode = " << m_encapMode); | 274 NS_LOG_LOGIC ("m_encapMode = " << m_encapMode); |
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1047 return true; | 1091 return true; |
1048 } | 1092 } |
1049 | 1093 |
1050 int64_t | 1094 int64_t |
1051 CsmaNetDevice::AssignStreams (int64_t stream) | 1095 CsmaNetDevice::AssignStreams (int64_t stream) |
1052 { | 1096 { |
1053 return m_backoff.AssignStreams (stream); | 1097 return m_backoff.AssignStreams (stream); |
1054 } | 1098 } |
1055 | 1099 |
1056 } // namespace ns3 | 1100 } // namespace ns3 |
LEFT | RIGHT |