Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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) 2006 Georgia Tech Research Corporation | 3 // Copyright (c) 2006 Georgia Tech Research Corporation |
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 #include "ipv4-raw-socket-impl.h" | 42 #include "ipv4-raw-socket-impl.h" |
43 | 43 |
44 NS_LOG_COMPONENT_DEFINE ("Ipv4L3Protocol"); | 44 NS_LOG_COMPONENT_DEFINE ("Ipv4L3Protocol"); |
45 | 45 |
46 namespace ns3 { | 46 namespace ns3 { |
47 | 47 |
48 const uint16_t Ipv4L3Protocol::PROT_NUMBER = 0x0800; | 48 const uint16_t Ipv4L3Protocol::PROT_NUMBER = 0x0800; |
49 | 49 |
50 NS_OBJECT_ENSURE_REGISTERED (Ipv4L3Protocol); | 50 NS_OBJECT_ENSURE_REGISTERED (Ipv4L3Protocol); |
51 | 51 |
52 TypeId | 52 TypeId |
53 Ipv4L3Protocol::GetTypeId (void) | 53 Ipv4L3Protocol::GetTypeId (void) |
54 { | 54 { |
55 static TypeId tid = TypeId ("ns3::Ipv4L3Protocol") | 55 static TypeId tid = TypeId ("ns3::Ipv4L3Protocol") |
56 .SetParent<Ipv4> () | 56 .SetParent<Ipv4> () |
57 .AddConstructor<Ipv4L3Protocol> () | 57 .AddConstructor<Ipv4L3Protocol> () |
58 .AddAttribute ("DefaultTtl", "The TTL value set by default on all outgoing p ackets generated on this node.", | 58 .AddAttribute ("DefaultTtl", "The TTL value set by default on all outgoing p ackets generated on this node.", |
59 UintegerValue (64), | 59 UintegerValue (64), |
60 MakeUintegerAccessor (&Ipv4L3Protocol::m_defaultTtl), | 60 MakeUintegerAccessor (&Ipv4L3Protocol::m_defaultTtl), |
61 MakeUintegerChecker<uint8_t> ()) | 61 MakeUintegerChecker<uint8_t> ()) |
62 .AddAttribute ("WaitReplyTimeout", | 62 .AddAttribute ("FragmentExpirationTimeout", |
Vedran Miletić
2011/06/24 15:51:05
Why is it named WaitReply?
Tommaso Pecorella
2011/06/24 19:49:00
Honestly, I can't remember. The only twisted expla
| |
63 "When this timeout expires, the fragments will be cleared fro m the buffer", | 63 "When this timeout expires, the fragments will be cleared fro m the buffer.", |
64 TimeValue (Seconds (30)), | 64 TimeValue (Seconds (30)), |
65 MakeTimeAccessor (&Ipv4L3Protocol::m_waitFragmentsTimeout), | 65 MakeTimeAccessor (&Ipv4L3Protocol::m_fragmentExpirationTimeou t), |
66 MakeTimeChecker ()) | 66 MakeTimeChecker ()) |
67 .AddTraceSource ("Tx", "Send ipv4 packet to outgoing interface.", | 67 .AddTraceSource ("Tx", "Send ipv4 packet to outgoing interface.", |
68 MakeTraceSourceAccessor (&Ipv4L3Protocol::m_txTrace)) | 68 MakeTraceSourceAccessor (&Ipv4L3Protocol::m_txTrace)) |
69 .AddTraceSource ("Rx", "Receive ipv4 packet from incoming interface.", | 69 .AddTraceSource ("Rx", "Receive ipv4 packet from incoming interface.", |
70 MakeTraceSourceAccessor (&Ipv4L3Protocol::m_rxTrace)) | 70 MakeTraceSourceAccessor (&Ipv4L3Protocol::m_rxTrace)) |
71 .AddTraceSource ("Drop", "Drop ipv4 packet", | 71 .AddTraceSource ("Drop", "Drop ipv4 packet", |
72 MakeTraceSourceAccessor (&Ipv4L3Protocol::m_dropTrace)) | 72 MakeTraceSourceAccessor (&Ipv4L3Protocol::m_dropTrace)) |
73 .AddAttribute ("InterfaceList", "The set of Ipv4 interfaces associated to th is Ipv4 stack.", | 73 .AddAttribute ("InterfaceList", "The set of Ipv4 interfaces associated to th is Ipv4 stack.", |
74 ObjectVectorValue (), | 74 ObjectVectorValue (), |
75 MakeObjectVectorAccessor (&Ipv4L3Protocol::m_interfaces), | 75 MakeObjectVectorAccessor (&Ipv4L3Protocol::m_interfaces), |
76 MakeObjectVectorChecker<Ipv4Interface> ()) | 76 MakeObjectVectorChecker<Ipv4Interface> ()) |
77 | 77 |
78 .AddTraceSource ("SendOutgoing", "A newly-generated packet by this node is a bout to be queued for transmission", | 78 .AddTraceSource ("SendOutgoing", "A newly-generated packet by this node is a bout to be queued for transmission", |
79 MakeTraceSourceAccessor (&Ipv4L3Protocol::m_sendOutgoingTra ce)) | 79 MakeTraceSourceAccessor (&Ipv4L3Protocol::m_sendOutgoingTra ce)) |
80 .AddTraceSource ("UnicastForward", "A unicast IPv4 packet was received by th is node and is being forwarded to another node", | 80 .AddTraceSource ("UnicastForward", "A unicast IPv4 packet was received by th is node and is being forwarded to another node", |
81 MakeTraceSourceAccessor (&Ipv4L3Protocol::m_unicastForwardT race)) | 81 MakeTraceSourceAccessor (&Ipv4L3Protocol::m_unicastForwardT race)) |
82 .AddTraceSource ("LocalDeliver", "An IPv4 packet was received by/for this no de, and it is being forward up the stack", | 82 .AddTraceSource ("LocalDeliver", "An IPv4 packet was received by/for this no de, and it is being forward up the stack", |
83 MakeTraceSourceAccessor (&Ipv4L3Protocol::m_localDeliverTra ce)) | 83 MakeTraceSourceAccessor (&Ipv4L3Protocol::m_localDeliverTra ce)) |
84 | 84 |
85 ; | 85 ; |
86 return tid; | 86 return tid; |
87 } | 87 } |
88 | 88 |
89 Ipv4L3Protocol::Ipv4L3Protocol () | 89 Ipv4L3Protocol::Ipv4L3Protocol() |
90 : m_identification (0) | 90 : m_identification (0) |
91 { | 91 { |
92 NS_LOG_FUNCTION (this); | 92 NS_LOG_FUNCTION (this); |
93 } | 93 } |
94 | 94 |
95 Ipv4L3Protocol::~Ipv4L3Protocol () | 95 Ipv4L3Protocol::~Ipv4L3Protocol () |
96 { | 96 { |
97 NS_LOG_FUNCTION (this); | 97 NS_LOG_FUNCTION (this); |
98 } | 98 } |
99 | 99 |
(...skipping 21 matching lines...) Expand all Loading... | |
121 } | 121 } |
122 | 122 |
123 void | 123 void |
124 Ipv4L3Protocol::SetNode (Ptr<Node> node) | 124 Ipv4L3Protocol::SetNode (Ptr<Node> node) |
125 { | 125 { |
126 m_node = node; | 126 m_node = node; |
127 // Add a LoopbackNetDevice if needed, and an Ipv4Interface on top of it | 127 // Add a LoopbackNetDevice if needed, and an Ipv4Interface on top of it |
128 SetupLoopback (); | 128 SetupLoopback (); |
129 } | 129 } |
130 | 130 |
131 Ptr<Socket> | 131 Ptr<Socket> |
132 Ipv4L3Protocol::CreateRawSocket (void) | 132 Ipv4L3Protocol::CreateRawSocket (void) |
133 { | 133 { |
134 NS_LOG_FUNCTION (this); | 134 NS_LOG_FUNCTION (this); |
135 Ptr<Ipv4RawSocketImpl> socket = CreateObject<Ipv4RawSocketImpl> (); | 135 Ptr<Ipv4RawSocketImpl> socket = CreateObject<Ipv4RawSocketImpl> (); |
136 socket->SetNode (m_node); | 136 socket->SetNode (m_node); |
137 m_sockets.push_back (socket); | 137 m_sockets.push_back (socket); |
138 return socket; | 138 return socket; |
139 } | 139 } |
140 void | 140 void |
141 Ipv4L3Protocol::DeleteRawSocket (Ptr<Socket> socket) | 141 Ipv4L3Protocol::DeleteRawSocket (Ptr<Socket> socket) |
142 { | 142 { |
143 NS_LOG_FUNCTION (this << socket); | 143 NS_LOG_FUNCTION (this << socket); |
144 for (SocketList::iterator i = m_sockets.begin (); i != m_sockets.end (); ++i) | 144 for (SocketList::iterator i = m_sockets.begin (); i != m_sockets.end (); ++i) |
145 { | 145 { |
146 if ((*i) == socket) | 146 if ((*i) == socket) |
147 { | 147 { |
148 m_sockets.erase (i); | 148 m_sockets.erase (i); |
149 return; | 149 return; |
150 } | 150 } |
151 } | 151 } |
152 return; | 152 return; |
153 } | 153 } |
154 /* | 154 /* |
155 * This method is called by AddAgregate and completes the aggregation | 155 * This method is called by AddAgregate and completes the aggregation |
156 * by setting the node in the ipv4 stack | 156 * by setting the node in the ipv4 stack |
157 */ | 157 */ |
158 void | 158 void |
159 Ipv4L3Protocol::NotifyNewAggregate () | 159 Ipv4L3Protocol::NotifyNewAggregate () |
160 { | 160 { |
161 if (m_node == 0) | 161 if (m_node == 0) |
162 { | 162 { |
163 Ptr<Node>node = this->GetObject<Node> (); | 163 Ptr<Node>node = this->GetObject<Node>(); |
164 // verify that it's a valid node and that | 164 // verify that it's a valid node and that |
165 // the node has not been set before | 165 // the node has not been set before |
166 if (node != 0) | 166 if (node != 0) |
167 { | 167 { |
168 this->SetNode (node); | 168 this->SetNode (node); |
169 } | 169 } |
170 } | 170 } |
171 Object::NotifyNewAggregate (); | 171 Object::NotifyNewAggregate (); |
172 } | 172 } |
173 | 173 |
174 void | 174 void |
175 Ipv4L3Protocol::SetRoutingProtocol (Ptr<Ipv4RoutingProtocol> routingProtocol) | 175 Ipv4L3Protocol::SetRoutingProtocol (Ptr<Ipv4RoutingProtocol> routingProtocol) |
176 { | 176 { |
177 NS_LOG_FUNCTION (this); | 177 NS_LOG_FUNCTION (this); |
178 m_routingProtocol = routingProtocol; | 178 m_routingProtocol = routingProtocol; |
179 m_routingProtocol->SetIpv4 (this); | 179 m_routingProtocol->SetIpv4 (this); |
180 } | 180 } |
181 | 181 |
182 | 182 |
183 Ptr<Ipv4RoutingProtocol> | 183 Ptr<Ipv4RoutingProtocol> |
184 Ipv4L3Protocol::GetRoutingProtocol (void) const | 184 Ipv4L3Protocol::GetRoutingProtocol (void) const |
185 { | 185 { |
186 return m_routingProtocol; | 186 return m_routingProtocol; |
187 } | 187 } |
188 | 188 |
189 void | 189 void |
190 Ipv4L3Protocol::DoDispose (void) | 190 Ipv4L3Protocol::DoDispose (void) |
191 { | 191 { |
192 NS_LOG_FUNCTION (this); | 192 NS_LOG_FUNCTION (this); |
193 for (L4List_t::iterator i = m_protocols.begin (); i != m_protocols.end (); ++i ) | 193 for (L4List_t::iterator i = m_protocols.begin (); i != m_protocols.end (); ++i ) |
194 { | 194 { |
195 *i = 0; | 195 *i = 0; |
196 } | 196 } |
197 m_protocols.clear (); | 197 m_protocols.clear (); |
198 | 198 |
199 for (Ipv4InterfaceList::iterator i = m_interfaces.begin (); i != m_interfaces. end (); ++i) | 199 for (Ipv4InterfaceList::iterator i = m_interfaces.begin (); i != m_interfaces. end (); ++i) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 // First check whether an existing LoopbackNetDevice exists on the node | 234 // First check whether an existing LoopbackNetDevice exists on the node |
235 for (uint32_t i = 0; i < m_node->GetNDevices (); i++) | 235 for (uint32_t i = 0; i < m_node->GetNDevices (); i++) |
236 { | 236 { |
237 if (device = DynamicCast<LoopbackNetDevice> (m_node->GetDevice (i))) | 237 if (device = DynamicCast<LoopbackNetDevice> (m_node->GetDevice (i))) |
238 { | 238 { |
239 break; | 239 break; |
240 } | 240 } |
241 } | 241 } |
242 if (device == 0) | 242 if (device == 0) |
243 { | 243 { |
244 device = CreateObject<LoopbackNetDevice> (); | 244 device = CreateObject<LoopbackNetDevice> (); |
245 m_node->AddDevice (device); | 245 m_node->AddDevice (device); |
246 } | 246 } |
247 interface->SetDevice (device); | 247 interface->SetDevice (device); |
248 interface->SetNode (m_node); | 248 interface->SetNode (m_node); |
249 Ipv4InterfaceAddress ifaceAddr = Ipv4InterfaceAddress (Ipv4Address::GetLoopbac k (), Ipv4Mask::GetLoopback ()); | 249 Ipv4InterfaceAddress ifaceAddr = Ipv4InterfaceAddress (Ipv4Address::GetLoopbac k (), Ipv4Mask::GetLoopback ()); |
250 interface->AddAddress (ifaceAddr); | 250 interface->AddAddress (ifaceAddr); |
251 uint32_t index = AddIpv4Interface (interface); | 251 uint32_t index = AddIpv4Interface (interface); |
252 Ptr<Node> node = GetObject<Node> (); | 252 Ptr<Node> node = GetObject<Node> (); |
253 node->RegisterProtocolHandler (MakeCallback (&Ipv4L3Protocol::Receive, this), | 253 node->RegisterProtocolHandler (MakeCallback (&Ipv4L3Protocol::Receive, this), |
254 Ipv4L3Protocol::PROT_NUMBER, device); | 254 Ipv4L3Protocol::PROT_NUMBER, device); |
255 interface->SetUp (); | 255 interface->SetUp (); |
256 if (m_routingProtocol != 0) | 256 if (m_routingProtocol != 0) |
257 { | 257 { |
258 m_routingProtocol->NotifyInterfaceUp (index); | 258 m_routingProtocol->NotifyInterfaceUp (index); |
259 } | 259 } |
260 } | 260 } |
261 | 261 |
262 void | 262 void |
263 Ipv4L3Protocol::SetDefaultTtl (uint8_t ttl) | 263 Ipv4L3Protocol::SetDefaultTtl (uint8_t ttl) |
264 { | 264 { |
265 m_defaultTtl = ttl; | 265 m_defaultTtl = ttl; |
266 } | 266 } |
267 | 267 |
268 uint32_t | 268 uint32_t |
269 Ipv4L3Protocol::AddInterface (Ptr<NetDevice> device) | 269 Ipv4L3Protocol::AddInterface (Ptr<NetDevice> device) |
270 { | 270 { |
271 NS_LOG_FUNCTION (this << &device); | 271 NS_LOG_FUNCTION (this << &device); |
272 | 272 |
273 Ptr<Node> node = GetObject<Node> (); | 273 Ptr<Node> node = GetObject<Node> (); |
274 node->RegisterProtocolHandler (MakeCallback (&Ipv4L3Protocol::Receive, this), | 274 node->RegisterProtocolHandler (MakeCallback (&Ipv4L3Protocol::Receive, this), |
275 Ipv4L3Protocol::PROT_NUMBER, device); | 275 Ipv4L3Protocol::PROT_NUMBER, device); |
276 node->RegisterProtocolHandler (MakeCallback (&ArpL3Protocol::Receive, PeekPoin ter (GetObject<ArpL3Protocol> ())), | 276 node->RegisterProtocolHandler (MakeCallback (&ArpL3Protocol::Receive, PeekPoin ter (GetObject<ArpL3Protocol> ())), |
277 ArpL3Protocol::PROT_NUMBER, device); | 277 ArpL3Protocol::PROT_NUMBER, device); |
278 | 278 |
279 Ptr<Ipv4Interface> interface = CreateObject<Ipv4Interface> (); | 279 Ptr<Ipv4Interface> interface = CreateObject<Ipv4Interface> (); |
280 interface->SetNode (m_node); | 280 interface->SetNode (m_node); |
281 interface->SetDevice (device); | 281 interface->SetDevice (device); |
282 interface->SetForwarding (m_ipForward); | 282 interface->SetForwarding (m_ipForward); |
283 return AddIpv4Interface (interface); | 283 return AddIpv4Interface (interface); |
284 } | 284 } |
285 | 285 |
286 uint32_t | 286 uint32_t |
287 Ipv4L3Protocol::AddIpv4Interface (Ptr<Ipv4Interface>interface) | 287 Ipv4L3Protocol::AddIpv4Interface (Ptr<Ipv4Interface>interface) |
288 { | 288 { |
289 NS_LOG_FUNCTION (this << interface); | 289 NS_LOG_FUNCTION (this << interface); |
290 uint32_t index = m_interfaces.size (); | 290 uint32_t index = m_interfaces.size (); |
291 m_interfaces.push_back (interface); | 291 m_interfaces.push_back (interface); |
292 return index; | 292 return index; |
293 } | 293 } |
294 | 294 |
295 Ptr<Ipv4Interface> | 295 Ptr<Ipv4Interface> |
296 Ipv4L3Protocol::GetInterface (uint32_t index) const | 296 Ipv4L3Protocol::GetInterface (uint32_t index) const |
297 { | 297 { |
298 if (index < m_interfaces.size ()) | 298 if (index < m_interfaces.size ()) |
299 { | 299 { |
300 return m_interfaces[index]; | 300 return m_interfaces[index]; |
301 } | 301 } |
302 return 0; | 302 return 0; |
303 } | 303 } |
304 | 304 |
305 uint32_t | 305 uint32_t |
306 Ipv4L3Protocol::GetNInterfaces (void) const | 306 Ipv4L3Protocol::GetNInterfaces (void) const |
307 { | 307 { |
308 return m_interfaces.size (); | 308 return m_interfaces.size (); |
309 } | 309 } |
310 | 310 |
311 int32_t | 311 int32_t |
312 Ipv4L3Protocol::GetInterfaceForAddress ( | 312 Ipv4L3Protocol::GetInterfaceForAddress ( |
313 Ipv4Address address) const | 313 Ipv4Address address) const |
314 { | 314 { |
315 int32_t interface = 0; | 315 int32_t interface = 0; |
316 for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); | 316 for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); |
317 i != m_interfaces.end (); | 317 i != m_interfaces.end (); |
318 i++, interface++) | 318 i++, interface++) |
319 { | 319 { |
320 for (uint32_t j = 0; j < (*i)->GetNAddresses (); j++) | 320 for (uint32_t j = 0; j < (*i)->GetNAddresses (); j++) |
321 { | 321 { |
322 if ((*i)->GetAddress (j).GetLocal () == address) | 322 if ((*i)->GetAddress (j).GetLocal () == address) |
323 { | 323 { |
324 return interface; | 324 return interface; |
325 } | 325 } |
326 } | 326 } |
327 } | 327 } |
328 | 328 |
329 return -1; | 329 return -1; |
330 } | 330 } |
331 | 331 |
332 int32_t | 332 int32_t |
333 Ipv4L3Protocol::GetInterfaceForPrefix ( | 333 Ipv4L3Protocol::GetInterfaceForPrefix ( |
334 Ipv4Address address, | 334 Ipv4Address address, |
335 Ipv4Mask mask) const | 335 Ipv4Mask mask) const |
336 { | 336 { |
337 int32_t interface = 0; | 337 int32_t interface = 0; |
338 for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); | 338 for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); |
339 i != m_interfaces.end (); | 339 i != m_interfaces.end (); |
340 i++, interface++) | 340 i++, interface++) |
341 { | 341 { |
342 for (uint32_t j = 0; j < (*i)->GetNAddresses (); j++) | 342 for (uint32_t j = 0; j < (*i)->GetNAddresses (); j++) |
343 { | 343 { |
344 if ((*i)->GetAddress (j).GetLocal ().CombineMask (mask) == address.Com bineMask (mask)) | 344 if ((*i)->GetAddress (j).GetLocal ().CombineMask (mask) == address.Com bineMask (mask)) |
345 { | 345 { |
346 return interface; | 346 return interface; |
347 } | 347 } |
348 } | 348 } |
349 } | 349 } |
350 | 350 |
351 return -1; | 351 return -1; |
352 } | 352 } |
353 | 353 |
354 int32_t | 354 int32_t |
355 Ipv4L3Protocol::GetInterfaceForDevice ( | 355 Ipv4L3Protocol::GetInterfaceForDevice ( |
356 Ptr<const NetDevice> device) const | 356 Ptr<const NetDevice> device) const |
357 { | 357 { |
358 int32_t interface = 0; | 358 int32_t interface = 0; |
359 for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); | 359 for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); |
360 i != m_interfaces.end (); | 360 i != m_interfaces.end (); |
361 i++, interface++) | 361 i++, interface++) |
362 { | 362 { |
363 if ((*i)->GetDevice () == device) | 363 if ((*i)->GetDevice () == device) |
364 { | 364 { |
365 return interface; | 365 return interface; |
366 } | 366 } |
367 } | 367 } |
368 | 368 |
369 return -1; | 369 return -1; |
370 } | 370 } |
(...skipping 29 matching lines...) Expand all Loading... | |
400 } | 400 } |
401 } | 401 } |
402 | 402 |
403 if (address.IsBroadcast ()) | 403 if (address.IsBroadcast ()) |
404 { | 404 { |
405 NS_LOG_LOGIC ("For me (Ipv4Addr broadcast address)"); | 405 NS_LOG_LOGIC ("For me (Ipv4Addr broadcast address)"); |
406 return true; | 406 return true; |
407 } | 407 } |
408 | 408 |
409 if (GetWeakEsModel ()) // Check other interfaces | 409 if (GetWeakEsModel ()) // Check other interfaces |
410 { | 410 { |
411 for (uint32_t j = 0; j < GetNInterfaces (); j++) | 411 for (uint32_t j = 0; j < GetNInterfaces (); j++) |
412 { | 412 { |
413 if (j == uint32_t (iif)) | 413 if (j == uint32_t (iif)) continue; |
414 { | |
415 continue; | |
416 } | |
417 for (uint32_t i = 0; i < GetNAddresses (j); i++) | 414 for (uint32_t i = 0; i < GetNAddresses (j); i++) |
418 { | 415 { |
419 Ipv4InterfaceAddress iaddr = GetAddress (j, i); | 416 Ipv4InterfaceAddress iaddr = GetAddress (j, i); |
420 if (address == iaddr.GetLocal ()) | 417 if (address == iaddr.GetLocal ()) |
421 { | 418 { |
422 NS_LOG_LOGIC ("For me (destination " << address << " match) on another interface"); | 419 NS_LOG_LOGIC ("For me (destination " << address << " match) on another interface"); |
423 return true; | 420 return true; |
424 } | 421 } |
425 // This is a small corner case: match another interface's broadc ast address | 422 // This is a small corner case: match another interface's broadc ast address |
426 if (address == iaddr.GetBroadcast ()) | 423 if (address == iaddr.GetBroadcast ()) |
427 { | 424 { |
428 NS_LOG_LOGIC ("For me (interface broadcast address on another interface)"); | 425 NS_LOG_LOGIC ("For me (interface broadcast address on another interface)"); |
429 return true; | 426 return true; |
430 } | 427 } |
431 } | 428 } |
432 } | 429 } |
433 } | 430 } |
434 return false; | 431 return false; |
435 } | 432 } |
436 | 433 |
437 void | 434 void |
438 Ipv4L3Protocol::Receive ( Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t p rotocol, const Address &from, | 435 Ipv4L3Protocol::Receive ( Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t p rotocol, const Address &from, |
439 const Address &to, NetDevice::PacketType packetType) | 436 const Address &to, NetDevice::PacketType packetType) |
440 { | 437 { |
441 NS_LOG_FUNCTION (this << &device << p << protocol << from); | 438 NS_LOG_FUNCTION (this << &device << p << protocol << from); |
442 | 439 |
443 NS_LOG_LOGIC ("Packet from " << from << " received on node " << | 440 NS_LOG_LOGIC ("Packet from " << from << " received on node " << |
444 m_node->GetId ()); | 441 m_node->GetId ()); |
445 | 442 |
446 uint32_t interface = 0; | 443 uint32_t interface = 0; |
447 Ptr<Packet> packet = p->Copy (); | 444 Ptr<Packet> packet = p->Copy (); |
448 | 445 |
449 Ptr<Ipv4Interface> ipv4Interface; | 446 Ptr<Ipv4Interface> ipv4Interface; |
450 for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); | 447 for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); |
451 i != m_interfaces.end (); | 448 i != m_interfaces.end (); |
452 i++, interface++) | 449 i++, interface++) |
453 { | 450 { |
454 ipv4Interface = *i; | 451 ipv4Interface = *i; |
455 if (ipv4Interface->GetDevice () == device) | 452 if (ipv4Interface->GetDevice () == device) |
456 { | 453 { |
457 if (ipv4Interface->IsUp ()) | 454 if (ipv4Interface->IsUp ()) |
458 { | 455 { |
459 m_rxTrace (packet, m_node->GetObject<Ipv4> (), interface); | 456 m_rxTrace (packet, m_node->GetObject<Ipv4> (), interface); |
460 break; | 457 break; |
461 } | 458 } |
(...skipping 14 matching lines...) Expand all Loading... | |
476 ipHeader.EnableChecksum (); | 473 ipHeader.EnableChecksum (); |
477 } | 474 } |
478 packet->RemoveHeader (ipHeader); | 475 packet->RemoveHeader (ipHeader); |
479 | 476 |
480 // Trim any residual frame padding from underlying devices | 477 // Trim any residual frame padding from underlying devices |
481 if (ipHeader.GetPayloadSize () < packet->GetSize ()) | 478 if (ipHeader.GetPayloadSize () < packet->GetSize ()) |
482 { | 479 { |
483 packet->RemoveAtEnd (packet->GetSize () - ipHeader.GetPayloadSize ()); | 480 packet->RemoveAtEnd (packet->GetSize () - ipHeader.GetPayloadSize ()); |
484 } | 481 } |
485 | 482 |
486 if (!ipHeader.IsChecksumOk ()) | 483 if (!ipHeader.IsChecksumOk ()) |
487 { | 484 { |
488 NS_LOG_LOGIC ("Dropping received packet -- checksum not ok"); | 485 NS_LOG_LOGIC ("Dropping received packet -- checksum not ok"); |
489 m_dropTrace (ipHeader, packet, DROP_BAD_CHECKSUM, m_node->GetObject<Ipv4> (), interface); | 486 m_dropTrace (ipHeader, packet, DROP_BAD_CHECKSUM, m_node->GetObject<Ipv4> (), interface); |
490 return; | 487 return; |
491 } | 488 } |
492 | 489 |
493 for (SocketList::iterator i = m_sockets.begin (); i != m_sockets.end (); ++i) | 490 for (SocketList::iterator i = m_sockets.begin (); i != m_sockets.end (); ++i) |
494 { | 491 { |
495 NS_LOG_LOGIC ("Forwarding to raw socket"); | 492 NS_LOG_LOGIC ("Forwarding to raw socket"); |
496 Ptr<Ipv4RawSocketImpl> socket = *i; | 493 Ptr<Ipv4RawSocketImpl> socket = *i; |
497 socket->ForwardUp (packet, ipHeader, ipv4Interface); | 494 socket->ForwardUp (packet, ipHeader, ipv4Interface); |
498 } | 495 } |
499 | 496 |
500 NS_ASSERT_MSG (m_routingProtocol != 0, "Need a routing protocol object to proc ess packets"); | 497 NS_ASSERT_MSG (m_routingProtocol != 0, "Need a routing protocol object to proc ess packets"); |
501 if (!m_routingProtocol->RouteInput (packet, ipHeader, device, | 498 if (!m_routingProtocol->RouteInput (packet, ipHeader, device, |
502 MakeCallback (&Ipv4L3Protocol::IpForward, this), | 499 MakeCallback (&Ipv4L3Protocol::IpForward, this), |
503 MakeCallback (&Ipv4L3Protocol::IpMulticast Forward, this), | 500 MakeCallback (&Ipv4L3Protocol::IpMulticast Forward, this), |
504 MakeCallback (&Ipv4L3Protocol::LocalDelive r, this), | 501 MakeCallback (&Ipv4L3Protocol::LocalDelive r, this), |
505 MakeCallback (&Ipv4L3Protocol::RouteInputE rror, this) | 502 MakeCallback (&Ipv4L3Protocol::RouteInputE rror, this) |
506 )) | 503 )) |
507 { | 504 { |
508 NS_LOG_WARN ("No route found for forwarding packet. Drop."); | 505 NS_LOG_WARN ("No route found for forwarding packet. Drop."); |
509 m_dropTrace (ipHeader, packet, DROP_NO_ROUTE, m_node->GetObject<Ipv4> (), interface); | 506 m_dropTrace (ipHeader, packet, DROP_NO_ROUTE, m_node->GetObject<Ipv4> (), interface); |
510 } | 507 } |
511 | 508 |
512 | 509 |
513 } | 510 } |
514 | 511 |
515 Ptr<Icmpv4L4Protocol> | 512 Ptr<Icmpv4L4Protocol> |
516 Ipv4L3Protocol::GetIcmp (void) const | 513 Ipv4L3Protocol::GetIcmp (void) const |
517 { | 514 { |
518 Ptr<Ipv4L4Protocol> prot = GetProtocol (Icmpv4L4Protocol::GetStaticProtocolNum ber ()); | 515 Ptr<Ipv4L4Protocol> prot = GetProtocol (Icmpv4L4Protocol::GetStaticProtocolNum ber ()); |
519 if (prot != 0) | 516 if (prot != 0) |
520 { | 517 { |
521 return prot->GetObject<Icmpv4L4Protocol> (); | 518 return prot->GetObject<Icmpv4L4Protocol> (); |
522 } | 519 } |
523 else | 520 else |
524 { | 521 { |
525 return 0; | 522 return 0; |
526 } | 523 } |
527 } | 524 } |
528 | 525 |
529 bool | 526 bool |
530 Ipv4L3Protocol::IsUnicast (Ipv4Address ad, Ipv4Mask interfaceMask) const | 527 Ipv4L3Protocol::IsUnicast (Ipv4Address ad, Ipv4Mask interfaceMask) const |
531 { | 528 { |
532 return !ad.IsMulticast () && !ad.IsSubnetDirectedBroadcast (interfaceMask); | 529 return !ad.IsMulticast () && !ad.IsSubnetDirectedBroadcast (interfaceMask); |
533 } | 530 } |
534 | 531 |
535 void | 532 void |
536 Ipv4L3Protocol::SendWithHeader (Ptr<Packet> packet, | 533 Ipv4L3Protocol::SendWithHeader (Ptr<Packet> packet, |
537 Ipv4Header ipHeader, | 534 Ipv4Header ipHeader, |
538 Ptr<Ipv4Route> route) | 535 Ptr<Ipv4Route> route) |
539 { | 536 { |
540 NS_LOG_FUNCTION (this << packet << ipHeader << route); | 537 NS_LOG_FUNCTION (this << packet << ipHeader << route); |
541 SendRealOut (route, packet, ipHeader); | 538 SendRealOut (route, packet, ipHeader); |
542 } | 539 } |
543 | 540 |
544 void | 541 void |
545 Ipv4L3Protocol::Send (Ptr<Packet> packet, | 542 Ipv4L3Protocol::Send (Ptr<Packet> packet, |
546 Ipv4Address source, | 543 Ipv4Address source, |
547 Ipv4Address destination, | 544 Ipv4Address destination, |
548 uint8_t protocol, | 545 uint8_t protocol, |
549 Ptr<Ipv4Route> route) | 546 Ptr<Ipv4Route> route) |
550 { | 547 { |
551 NS_LOG_FUNCTION (this << packet << source << destination << uint32_t (protocol ) << route); | 548 NS_LOG_FUNCTION (this << packet << source << destination << uint32_t (protocol ) << route); |
552 | 549 |
553 Ipv4Header ipHeader; | 550 Ipv4Header ipHeader; |
554 bool mayFragment = true; | 551 bool mayFragment = true; |
555 uint8_t ttl = m_defaultTtl; | 552 uint8_t ttl = m_defaultTtl; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
592 // 2) check: packet is destined to a subnet-directed broadcast address | 589 // 2) check: packet is destined to a subnet-directed broadcast address |
593 uint32_t ifaceIndex = 0; | 590 uint32_t ifaceIndex = 0; |
594 for (Ipv4InterfaceList::iterator ifaceIter = m_interfaces.begin (); | 591 for (Ipv4InterfaceList::iterator ifaceIter = m_interfaces.begin (); |
595 ifaceIter != m_interfaces.end (); ifaceIter++, ifaceIndex++) | 592 ifaceIter != m_interfaces.end (); ifaceIter++, ifaceIndex++) |
596 { | 593 { |
597 Ptr<Ipv4Interface> outInterface = *ifaceIter; | 594 Ptr<Ipv4Interface> outInterface = *ifaceIter; |
598 for (uint32_t j = 0; j < GetNAddresses (ifaceIndex); j++) | 595 for (uint32_t j = 0; j < GetNAddresses (ifaceIndex); j++) |
599 { | 596 { |
600 Ipv4InterfaceAddress ifAddr = GetAddress (ifaceIndex, j); | 597 Ipv4InterfaceAddress ifAddr = GetAddress (ifaceIndex, j); |
601 NS_LOG_LOGIC ("Testing address " << ifAddr.GetLocal () << " with mask " << ifAddr.GetMask ()); | 598 NS_LOG_LOGIC ("Testing address " << ifAddr.GetLocal () << " with mask " << ifAddr.GetMask ()); |
602 if (destination.IsSubnetDirectedBroadcast (ifAddr.GetMask ()) | 599 if (destination.IsSubnetDirectedBroadcast (ifAddr.GetMask ()) && |
603 && destination.CombineMask (ifAddr.GetMask ()) == ifAddr.GetLocal ().CombineMask (ifAddr.GetMask ()) ) | 600 destination.CombineMask (ifAddr.GetMask ()) == ifAddr.GetLocal (). CombineMask (ifAddr.GetMask ()) ) |
604 { | 601 { |
605 NS_LOG_LOGIC ("Ipv4L3Protocol::Send case 2: subnet directed bcast to " << ifAddr.GetLocal ()); | 602 NS_LOG_LOGIC ("Ipv4L3Protocol::Send case 2: subnet directed bcast to " << ifAddr.GetLocal ()); |
606 ipHeader = BuildHeader (source, destination, protocol, packet->Get Size (), ttl, mayFragment); | 603 ipHeader = BuildHeader (source, destination, protocol, packet->Get Size (), ttl, mayFragment); |
607 Ptr<Packet> packetCopy = packet->Copy (); | 604 Ptr<Packet> packetCopy = packet->Copy (); |
608 m_sendOutgoingTrace (ipHeader, packetCopy, ifaceIndex); | 605 m_sendOutgoingTrace (ipHeader, packetCopy, ifaceIndex); |
609 packetCopy->AddHeader (ipHeader); | 606 packetCopy->AddHeader (ipHeader); |
610 m_txTrace (packetCopy, m_node->GetObject<Ipv4> (), ifaceIndex); | 607 m_txTrace (packetCopy, m_node->GetObject<Ipv4> (), ifaceIndex); |
611 outInterface->Send (packetCopy, destination); | 608 outInterface->Send (packetCopy, destination); |
612 return; | 609 return; |
613 } | 610 } |
614 } | 611 } |
615 } | 612 } |
616 | 613 |
617 // 3) packet is not broadcast, and is passed in with a route entry | 614 // 3) packet is not broadcast, and is passed in with a route entry |
618 // with a valid Ipv4Address as the gateway | 615 // with a valid Ipv4Address as the gateway |
619 if (route && route->GetGateway () != Ipv4Address ()) | 616 if (route && route->GetGateway () != Ipv4Address ()) |
620 { | 617 { |
621 NS_LOG_LOGIC ("Ipv4L3Protocol::Send case 3: passed in with route"); | 618 NS_LOG_LOGIC ("Ipv4L3Protocol::Send case 3: passed in with route"); |
622 ipHeader = BuildHeader (source, destination, protocol, packet->GetSize (), ttl, mayFragment); | 619 ipHeader = BuildHeader (source, destination, protocol, packet->GetSize (), ttl, mayFragment); |
623 int32_t interface = GetInterfaceForDevice (route->GetOutputDevice ()); | 620 int32_t interface = GetInterfaceForDevice (route->GetOutputDevice ()); |
624 m_sendOutgoingTrace (ipHeader, packet, interface); | 621 m_sendOutgoingTrace (ipHeader, packet, interface); |
625 SendRealOut (route, packet->Copy (), ipHeader); | 622 SendRealOut (route, packet->Copy (), ipHeader); |
626 return; | 623 return; |
627 } | 624 } |
628 // 4) packet is not broadcast, and is passed in with a route entry but route-> GetGateway is not set (e.g., on-demand) | 625 // 4) packet is not broadcast, and is passed in with a route entry but route-> GetGateway is not set (e.g., on-demand) |
629 if (route && route->GetGateway () == Ipv4Address ()) | 626 if (route && route->GetGateway () == Ipv4Address ()) |
630 { | 627 { |
631 // This could arise because the synchronous RouteOutput() call | 628 // This could arise because the synchronous RouteOutput() call |
632 // returned to the transport protocol with a source address but | 629 // returned to the transport protocol with a source address but |
633 // there was no next hop available yet (since a route may need | 630 // there was no next hop available yet (since a route may need |
634 // to be queried). | 631 // to be queried). |
635 NS_FATAL_ERROR ("Ipv4L3Protocol::Send case 4: This case not yet implemente d"); | 632 NS_FATAL_ERROR ("Ipv4L3Protocol::Send case 4: This case not yet implemente d"); |
636 } | 633 } |
637 // 5) packet is not broadcast, and route is NULL (e.g., a raw socket call) | 634 // 5) packet is not broadcast, and route is NULL (e.g., a raw socket call) |
638 NS_LOG_LOGIC ("Ipv4L3Protocol::Send case 5: passed in with no route " << dest ination); | 635 NS_LOG_LOGIC ("Ipv4L3Protocol::Send case 5: passed in with no route " << dest ination); |
639 Socket::SocketErrno errno_; | 636 Socket::SocketErrno errno_; |
640 Ptr<NetDevice> oif (0); // unused for now | 637 Ptr<NetDevice> oif (0); // unused for now |
641 ipHeader = BuildHeader (source, destination, protocol, packet->GetSize (), ttl , mayFragment); | 638 ipHeader = BuildHeader (source, destination, protocol, packet->GetSize (), ttl , mayFragment); |
642 Ptr<Ipv4Route> newRoute; | 639 Ptr<Ipv4Route> newRoute; |
643 if (m_routingProtocol != 0) | 640 if (m_routingProtocol != 0) |
644 { | 641 { |
645 newRoute = m_routingProtocol->RouteOutput (packet, ipHeader, oif, errno_); | 642 newRoute = m_routingProtocol->RouteOutput (packet, ipHeader, oif, errno_); |
646 } | 643 } |
647 else | 644 else |
648 { | 645 { |
649 NS_LOG_ERROR ("Ipv4L3Protocol::Send: m_routingProtocol == 0"); | 646 NS_LOG_ERROR ("Ipv4L3Protocol::Send: m_routingProtocol == 0"); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
741 outInterface->Send (packet, route->GetGateway ()); | 738 outInterface->Send (packet, route->GetGateway ()); |
742 } | 739 } |
743 } | 740 } |
744 else | 741 else |
745 { | 742 { |
746 NS_LOG_LOGIC ("Dropping -- outgoing interface is down: " << route->Get Gateway ()); | 743 NS_LOG_LOGIC ("Dropping -- outgoing interface is down: " << route->Get Gateway ()); |
747 Ipv4Header ipHeader; | 744 Ipv4Header ipHeader; |
748 packet->RemoveHeader (ipHeader); | 745 packet->RemoveHeader (ipHeader); |
749 m_dropTrace (ipHeader, packet, DROP_INTERFACE_DOWN, m_node->GetObject< Ipv4> (), interface); | 746 m_dropTrace (ipHeader, packet, DROP_INTERFACE_DOWN, m_node->GetObject< Ipv4> (), interface); |
750 } | 747 } |
751 } | 748 } |
752 else | 749 else |
753 { | 750 { |
754 if (outInterface->IsUp ()) | 751 if (outInterface->IsUp ()) |
755 { | 752 { |
756 NS_LOG_LOGIC ("Send to destination " << ipHeader.GetDestination ()); | 753 NS_LOG_LOGIC ("Send to destination " << ipHeader.GetDestination ()); |
757 if ( packet->GetSize () > outInterface->GetDevice ()->GetMtu () ) | 754 if ( packet->GetSize () > outInterface->GetDevice ()->GetMtu () ) |
758 { | 755 { |
759 std::list<Ptr<Packet> > listFragments; | 756 std::list<Ptr<Packet> > listFragments; |
760 DoFragmentation (packet, outInterface->GetDevice ()->GetMtu (), li stFragments); | 757 DoFragmentation (packet, outInterface->GetDevice ()->GetMtu (), li stFragments); |
761 for ( std::list<Ptr<Packet> >::iterator it = listFragments.begin ( ); it != listFragments.end (); it++ ) | 758 for ( std::list<Ptr<Packet> >::iterator it = listFragments.begin ( ); it != listFragments.end (); it++ ) |
762 { | 759 { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
822 { | 819 { |
823 NS_LOG_FUNCTION (this << rtentry << p << header); | 820 NS_LOG_FUNCTION (this << rtentry << p << header); |
824 NS_LOG_LOGIC ("Forwarding logic for node: " << m_node->GetId ()); | 821 NS_LOG_LOGIC ("Forwarding logic for node: " << m_node->GetId ()); |
825 // Forwarding | 822 // Forwarding |
826 Ipv4Header ipHeader = header; | 823 Ipv4Header ipHeader = header; |
827 Ptr<Packet> packet = p->Copy (); | 824 Ptr<Packet> packet = p->Copy (); |
828 int32_t interface = GetInterfaceForDevice (rtentry->GetOutputDevice ()); | 825 int32_t interface = GetInterfaceForDevice (rtentry->GetOutputDevice ()); |
829 ipHeader.SetTtl (ipHeader.GetTtl () - 1); | 826 ipHeader.SetTtl (ipHeader.GetTtl () - 1); |
830 if (ipHeader.GetTtl () == 0) | 827 if (ipHeader.GetTtl () == 0) |
831 { | 828 { |
832 // Do not reply to ICMP or to multicast/broadcast IP address | 829 // Do not reply to ICMP or to multicast/broadcast IP address |
833 if (ipHeader.GetProtocol () != Icmpv4L4Protocol::PROT_NUMBER | 830 if (ipHeader.GetProtocol () != Icmpv4L4Protocol::PROT_NUMBER && |
834 && ipHeader.GetDestination ().IsBroadcast () == false | 831 ipHeader.GetDestination ().IsBroadcast () == false && |
835 && ipHeader.GetDestination ().IsMulticast () == false) | 832 ipHeader.GetDestination ().IsMulticast () == false) |
836 { | 833 { |
837 Ptr<Icmpv4L4Protocol> icmp = GetIcmp (); | 834 Ptr<Icmpv4L4Protocol> icmp = GetIcmp (); |
838 icmp->SendTimeExceededTtl (ipHeader, packet); | 835 icmp->SendTimeExceededTtl (ipHeader, packet); |
839 } | 836 } |
840 NS_LOG_WARN ("TTL exceeded. Drop."); | 837 NS_LOG_WARN ("TTL exceeded. Drop."); |
841 m_dropTrace (header, packet, DROP_TTL_EXPIRED, m_node->GetObject<Ipv4> (), interface); | 838 m_dropTrace (header, packet, DROP_TTL_EXPIRED, m_node->GetObject<Ipv4> (), interface); |
842 return; | 839 return; |
843 } | 840 } |
844 m_unicastForwardTrace (ipHeader, packet, interface); | 841 m_unicastForwardTrace (ipHeader, packet, interface); |
845 SendRealOut (rtentry, packet, ipHeader); | 842 SendRealOut (rtentry, packet, ipHeader); |
(...skipping 19 matching lines...) Expand all Loading... | |
865 } | 862 } |
866 | 863 |
867 m_localDeliverTrace (ip, packet, iif); | 864 m_localDeliverTrace (ip, packet, iif); |
868 | 865 |
869 Ptr<Ipv4L4Protocol> protocol = GetProtocol (ip.GetProtocol ()); | 866 Ptr<Ipv4L4Protocol> protocol = GetProtocol (ip.GetProtocol ()); |
870 if (protocol != 0) | 867 if (protocol != 0) |
871 { | 868 { |
872 // we need to make a copy in the unlikely event we hit the | 869 // we need to make a copy in the unlikely event we hit the |
873 // RX_ENDPOINT_UNREACH codepath | 870 // RX_ENDPOINT_UNREACH codepath |
874 Ptr<Packet> copy = p->Copy (); | 871 Ptr<Packet> copy = p->Copy (); |
875 enum Ipv4L4Protocol::RxStatus status = | 872 enum Ipv4L4Protocol::RxStatus status = |
876 protocol->Receive (p, ip, GetInterface (iif)); | 873 protocol->Receive (p, ip, GetInterface (iif)); |
877 switch (status) | 874 switch (status) { |
878 { | |
879 case Ipv4L4Protocol::RX_OK: | 875 case Ipv4L4Protocol::RX_OK: |
880 // fall through | 876 // fall through |
881 case Ipv4L4Protocol::RX_ENDPOINT_CLOSED: | 877 case Ipv4L4Protocol::RX_ENDPOINT_CLOSED: |
882 // fall through | 878 // fall through |
883 case Ipv4L4Protocol::RX_CSUM_FAILED: | 879 case Ipv4L4Protocol::RX_CSUM_FAILED: |
884 break; | 880 break; |
885 case Ipv4L4Protocol::RX_ENDPOINT_UNREACH: | 881 case Ipv4L4Protocol::RX_ENDPOINT_UNREACH: |
886 if (ip.GetDestination ().IsBroadcast () == true | 882 if (ip.GetDestination ().IsBroadcast () == true || |
887 || ip.GetDestination ().IsMulticast () == true) | 883 ip.GetDestination ().IsMulticast () == true) |
888 { | 884 { |
889 break; // Do not reply to broadcast or multicast | 885 break; // Do not reply to broadcast or multicast |
890 } | 886 } |
891 // Another case to suppress ICMP is a subnet-directed broadcast | 887 // Another case to suppress ICMP is a subnet-directed broadcast |
892 bool subnetDirected = false; | 888 bool subnetDirected = false; |
893 for (uint32_t i = 0; i < GetNAddresses (iif); i++) | 889 for (uint32_t i = 0; i < GetNAddresses (iif); i++) |
894 { | 890 { |
895 Ipv4InterfaceAddress addr = GetAddress (iif, i); | 891 Ipv4InterfaceAddress addr = GetAddress (iif, i); |
896 if (addr.GetLocal ().CombineMask (addr.GetMask ()) == ip.GetDestin ation ().CombineMask (addr.GetMask ()) | 892 if (addr.GetLocal ().CombineMask (addr.GetMask ()) == ip.GetDestin ation ().CombineMask (addr.GetMask ()) && |
897 && ip.GetDestination ().IsSubnetDirectedBroadcast (addr.GetMas k ())) | 893 ip.GetDestination ().IsSubnetDirectedBroadcast (addr.GetMask ( ))) |
898 { | 894 { |
899 subnetDirected = true; | 895 subnetDirected = true; |
900 } | 896 } |
901 } | 897 } |
902 if (subnetDirected == false) | 898 if (subnetDirected == false) |
903 { | 899 { |
904 GetIcmp ()->SendDestUnreachPort (ip, copy); | 900 GetIcmp ()->SendDestUnreachPort (ip, copy); |
905 } | 901 } |
906 } | 902 } |
907 } | 903 } |
908 } | 904 } |
909 | 905 |
910 bool | 906 bool |
911 Ipv4L3Protocol::AddAddress (uint32_t i, Ipv4InterfaceAddress address) | 907 Ipv4L3Protocol::AddAddress (uint32_t i, Ipv4InterfaceAddress address) |
912 { | 908 { |
913 NS_LOG_FUNCTION (this << i << address); | 909 NS_LOG_FUNCTION (this << i << address); |
914 Ptr<Ipv4Interface> interface = GetInterface (i); | 910 Ptr<Ipv4Interface> interface = GetInterface (i); |
915 bool retVal = interface->AddAddress (address); | 911 bool retVal = interface->AddAddress (address); |
916 if (m_routingProtocol != 0) | 912 if (m_routingProtocol != 0) |
917 { | 913 { |
918 m_routingProtocol->NotifyAddAddress (i, address); | 914 m_routingProtocol->NotifyAddAddress (i, address); |
919 } | 915 } |
920 return retVal; | 916 return retVal; |
921 } | 917 } |
922 | 918 |
923 Ipv4InterfaceAddress | 919 Ipv4InterfaceAddress |
924 Ipv4L3Protocol::GetAddress (uint32_t interfaceIndex, uint32_t addressIndex) cons t | 920 Ipv4L3Protocol::GetAddress (uint32_t interfaceIndex, uint32_t addressIndex) cons t |
925 { | 921 { |
926 Ptr<Ipv4Interface> interface = GetInterface (interfaceIndex); | 922 Ptr<Ipv4Interface> interface = GetInterface (interfaceIndex); |
927 return interface->GetAddress (addressIndex); | 923 return interface->GetAddress (addressIndex); |
928 } | 924 } |
929 | 925 |
930 uint32_t | 926 uint32_t |
931 Ipv4L3Protocol::GetNAddresses (uint32_t interface) const | 927 Ipv4L3Protocol::GetNAddresses (uint32_t interface) const |
932 { | 928 { |
933 Ptr<Ipv4Interface> iface = GetInterface (interface); | 929 Ptr<Ipv4Interface> iface = GetInterface (interface); |
934 return iface->GetNAddresses (); | 930 return iface->GetNAddresses (); |
935 } | 931 } |
936 | 932 |
937 bool | 933 bool |
938 Ipv4L3Protocol::RemoveAddress (uint32_t i, uint32_t addressIndex) | 934 Ipv4L3Protocol::RemoveAddress (uint32_t i, uint32_t addressIndex) |
939 { | 935 { |
940 NS_LOG_FUNCTION (this << i << addressIndex); | 936 NS_LOG_FUNCTION (this << i << addressIndex); |
941 Ptr<Ipv4Interface> interface = GetInterface (i); | 937 Ptr<Ipv4Interface> interface = GetInterface (i); |
942 Ipv4InterfaceAddress address = interface->RemoveAddress (addressIndex); | 938 Ipv4InterfaceAddress address = interface->RemoveAddress (addressIndex); |
943 if (address != Ipv4InterfaceAddress ()) | 939 if (address != Ipv4InterfaceAddress ()) |
944 { | 940 { |
945 if (m_routingProtocol != 0) | 941 if (m_routingProtocol != 0) |
946 { | 942 { |
947 m_routingProtocol->NotifyRemoveAddress (i, address); | 943 m_routingProtocol->NotifyRemoveAddress (i, address); |
948 } | 944 } |
949 return true; | 945 return true; |
950 } | 946 } |
951 return false; | 947 return false; |
952 } | 948 } |
953 | 949 |
954 Ipv4Address | 950 Ipv4Address |
955 Ipv4L3Protocol::SelectSourceAddress (Ptr<const NetDevice> device, | 951 Ipv4L3Protocol::SelectSourceAddress (Ptr<const NetDevice> device, |
956 Ipv4Address dst, Ipv4InterfaceAddress::Inte rfaceAddressScope_e scope) | 952 Ipv4Address dst, Ipv4InterfaceAddress::Inte rfaceAddressScope_e scope) |
957 { | 953 { |
958 NS_LOG_FUNCTION (this << device << dst << scope); | 954 NS_LOG_FUNCTION (this << device << dst << scope); |
959 Ipv4Address addr ("0.0.0.0"); | 955 Ipv4Address addr ("0.0.0.0"); |
960 Ipv4InterfaceAddress iaddr; | 956 Ipv4InterfaceAddress iaddr; |
961 bool found = false; | 957 bool found = false; |
962 | 958 |
963 if (device != 0) | 959 if (device != 0) |
964 { | 960 { |
965 int32_t i = GetInterfaceForDevice (device); | 961 int32_t i = GetInterfaceForDevice (device); |
966 NS_ASSERT_MSG (i >= 0, "No device found on node"); | 962 NS_ASSERT_MSG (i >= 0, "No device found on node"); |
967 for (uint32_t j = 0; j < GetNAddresses (i); j++) | 963 for (uint32_t j = 0; j < GetNAddresses (i); j++) |
968 { | 964 { |
969 iaddr = GetAddress (i, j); | 965 iaddr = GetAddress (i, j); |
970 if (iaddr.IsSecondary ()) | 966 if (iaddr.IsSecondary ()) continue; |
971 { | 967 if (iaddr.GetScope () > scope) continue;· |
972 continue; | |
973 } | |
974 if (iaddr.GetScope () > scope) | |
975 { | |
976 continue; | |
977 } | |
978 if (dst.CombineMask (iaddr.GetMask ()) == iaddr.GetLocal ().CombineMa sk (iaddr.GetMask ()) ) | 968 if (dst.CombineMask (iaddr.GetMask ()) == iaddr.GetLocal ().CombineMa sk (iaddr.GetMask ()) ) |
979 { | 969 { |
980 return iaddr.GetLocal (); | 970 return iaddr.GetLocal (); |
981 } | 971 } |
982 if (!found) | 972 if (!found) |
983 { | 973 { |
984 addr = iaddr.GetLocal (); | 974 addr = iaddr.GetLocal (); |
985 found = true; | 975 found = true; |
986 } | 976 } |
987 } | 977 } |
988 } | 978 } |
989 if (found) | 979 if (found) |
990 { | 980 { |
991 return addr; | 981 return addr; |
992 } | 982 } |
993 | 983 |
994 // Iterate among all interfaces | 984 // Iterate among all interfaces |
995 for (uint32_t i = 0; i < GetNInterfaces (); i++) | 985 for (uint32_t i = 0; i < GetNInterfaces (); i++) |
996 { | 986 { |
997 for (uint32_t j = 0; j < GetNAddresses (i); j++) | 987 for (uint32_t j = 0; j < GetNAddresses (i); j++) |
998 { | 988 { |
999 iaddr = GetAddress (i, j); | 989 iaddr = GetAddress (i, j); |
1000 if (iaddr.IsSecondary ()) | 990 if (iaddr.IsSecondary ()) continue; |
1001 { | 991 if (iaddr.GetScope () != Ipv4InterfaceAddress::LINK |
1002 continue; | 992 && iaddr.GetScope () <= scope) |
1003 } | |
1004 if (iaddr.GetScope () != Ipv4InterfaceAddress::LINK | |
1005 && iaddr.GetScope () <= scope) | |
1006 { | 993 { |
1007 return iaddr.GetLocal (); | 994 return iaddr.GetLocal (); |
1008 } | 995 } |
1009 } | 996 } |
1010 } | 997 } |
1011 NS_LOG_WARN ("Could not find source address for " << dst << " and scope " | 998 NS_LOG_WARN ("Could not find source address for " << dst << " and scope " |
1012 << scope << ", returning 0") ; | 999 << scope << ", returning 0") ; |
1013 return addr; | 1000 return addr; |
1014 } | 1001 } |
1015 | 1002 |
1016 void | 1003 void |
1017 Ipv4L3Protocol::SetMetric (uint32_t i, uint16_t metric) | 1004 Ipv4L3Protocol::SetMetric (uint32_t i, uint16_t metric) |
1018 { | 1005 { |
1019 NS_LOG_FUNCTION (this << i << metric); | 1006 NS_LOG_FUNCTION (this << i << metric); |
1020 Ptr<Ipv4Interface> interface = GetInterface (i); | 1007 Ptr<Ipv4Interface> interface = GetInterface (i); |
1021 interface->SetMetric (metric); | 1008 interface->SetMetric (metric); |
1022 } | 1009 } |
1023 | 1010 |
1024 uint16_t | 1011 uint16_t |
1025 Ipv4L3Protocol::GetMetric (uint32_t i) const | 1012 Ipv4L3Protocol::GetMetric (uint32_t i) const |
1026 { | 1013 { |
1027 Ptr<Ipv4Interface> interface = GetInterface (i); | 1014 Ptr<Ipv4Interface> interface = GetInterface (i); |
1028 return interface->GetMetric (); | 1015 return interface->GetMetric (); |
1029 } | 1016 } |
1030 | 1017 |
1031 uint16_t | 1018 uint16_t |
1032 Ipv4L3Protocol::GetMtu (uint32_t i) const | 1019 Ipv4L3Protocol::GetMtu (uint32_t i) const |
1033 { | 1020 { |
1034 Ptr<Ipv4Interface> interface = GetInterface (i); | 1021 Ptr<Ipv4Interface> interface = GetInterface (i); |
1035 return interface->GetDevice ()->GetMtu (); | 1022 return interface->GetDevice ()->GetMtu (); |
1036 } | 1023 } |
1037 | 1024 |
1038 bool | 1025 bool |
1039 Ipv4L3Protocol::IsUp (uint32_t i) const | 1026 Ipv4L3Protocol::IsUp (uint32_t i) const |
1040 { | 1027 { |
1041 Ptr<Ipv4Interface> interface = GetInterface (i); | 1028 Ptr<Ipv4Interface> interface = GetInterface (i); |
1042 return interface->IsUp (); | 1029 return interface->IsUp (); |
1043 } | 1030 } |
1044 | 1031 |
1045 void | 1032 void |
1046 Ipv4L3Protocol::SetUp (uint32_t i) | 1033 Ipv4L3Protocol::SetUp (uint32_t i) |
1047 { | 1034 { |
1048 NS_LOG_FUNCTION (this << i); | 1035 NS_LOG_FUNCTION (this << i); |
1049 Ptr<Ipv4Interface> interface = GetInterface (i); | 1036 Ptr<Ipv4Interface> interface = GetInterface (i); |
1050 interface->SetUp (); | 1037 interface->SetUp (); |
1051 | 1038 |
1052 if (m_routingProtocol != 0) | 1039 if (m_routingProtocol != 0) |
1053 { | 1040 { |
1054 m_routingProtocol->NotifyInterfaceUp (i); | 1041 m_routingProtocol->NotifyInterfaceUp (i); |
1055 } | 1042 } |
1056 } | 1043 } |
1057 | 1044 |
1058 void | 1045 void |
1059 Ipv4L3Protocol::SetDown (uint32_t ifaceIndex) | 1046 Ipv4L3Protocol::SetDown (uint32_t ifaceIndex) |
1060 { | 1047 { |
1061 NS_LOG_FUNCTION (this << ifaceIndex); | 1048 NS_LOG_FUNCTION (this << ifaceIndex); |
1062 Ptr<Ipv4Interface> interface = GetInterface (ifaceIndex); | 1049 Ptr<Ipv4Interface> interface = GetInterface (ifaceIndex); |
1063 interface->SetDown (); | 1050 interface->SetDown (); |
1064 | 1051 |
1065 if (m_routingProtocol != 0) | 1052 if (m_routingProtocol != 0) |
1066 { | 1053 { |
1067 m_routingProtocol->NotifyInterfaceDown (ifaceIndex); | 1054 m_routingProtocol->NotifyInterfaceDown (ifaceIndex); |
1068 } | 1055 } |
1069 } | 1056 } |
1070 | 1057 |
1071 bool | 1058 bool |
1072 Ipv4L3Protocol::IsForwarding (uint32_t i) const | 1059 Ipv4L3Protocol::IsForwarding (uint32_t i) const |
1073 { | 1060 { |
1074 NS_LOG_FUNCTION (this << i); | 1061 NS_LOG_FUNCTION (this << i); |
1075 Ptr<Ipv4Interface> interface = GetInterface (i); | 1062 Ptr<Ipv4Interface> interface = GetInterface (i); |
1076 NS_LOG_LOGIC ("Forwarding state: " << interface->IsForwarding ()); | 1063 NS_LOG_LOGIC ("Forwarding state: " << interface->IsForwarding ()); |
1077 return interface->IsForwarding (); | 1064 return interface->IsForwarding (); |
1078 } | 1065 } |
1079 | 1066 |
1080 void | 1067 void |
1081 Ipv4L3Protocol::SetForwarding (uint32_t i, bool val) | 1068 Ipv4L3Protocol::SetForwarding (uint32_t i, bool val) |
1082 { | 1069 { |
1083 NS_LOG_FUNCTION (this << i); | 1070 NS_LOG_FUNCTION (this << i); |
1084 Ptr<Ipv4Interface> interface = GetInterface (i); | 1071 Ptr<Ipv4Interface> interface = GetInterface (i); |
1085 interface->SetForwarding (val); | 1072 interface->SetForwarding (val); |
1086 } | 1073 } |
1087 | 1074 |
1088 Ptr<NetDevice> | 1075 Ptr<NetDevice> |
1089 Ipv4L3Protocol::GetNetDevice (uint32_t i) | 1076 Ipv4L3Protocol::GetNetDevice (uint32_t i) |
1090 { | 1077 { |
1091 return GetInterface (i)->GetDevice (); | 1078 return GetInterface (i)->GetDevice (); |
1092 } | 1079 } |
1093 | 1080 |
1094 void | 1081 void |
1095 Ipv4L3Protocol::SetIpForward (bool forward) | 1082 Ipv4L3Protocol::SetIpForward (bool forward) |
1096 { | 1083 { |
1097 NS_LOG_FUNCTION (this << forward); | 1084 NS_LOG_FUNCTION (this << forward); |
1098 m_ipForward = forward; | 1085 m_ipForward = forward; |
1099 for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); i != m_inter faces.end (); i++) | 1086 for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); i != m_inter faces.end (); i++) |
1100 { | 1087 { |
1101 (*i)->SetForwarding (forward); | 1088 (*i)->SetForwarding (forward); |
1102 } | 1089 } |
1103 } | 1090 } |
1104 | 1091 |
1105 bool | 1092 bool |
1106 Ipv4L3Protocol::GetIpForward (void) const | 1093 Ipv4L3Protocol::GetIpForward (void) const |
1107 { | 1094 { |
1108 return m_ipForward; | 1095 return m_ipForward; |
1109 } | 1096 } |
1110 | 1097 |
1111 void | 1098 void |
1112 Ipv4L3Protocol::SetWeakEsModel (bool model) | 1099 Ipv4L3Protocol::SetWeakEsModel (bool model) |
1113 { | 1100 { |
1114 m_weakEsModel = model; | 1101 m_weakEsModel = model; |
1115 } | 1102 } |
1116 | 1103 |
1117 bool | 1104 bool |
1118 Ipv4L3Protocol::GetWeakEsModel (void) const | 1105 Ipv4L3Protocol::GetWeakEsModel (void) const |
1119 { | 1106 { |
1120 return m_weakEsModel; | 1107 return m_weakEsModel; |
1121 } | 1108 } |
1122 | 1109 |
1123 void | 1110 void |
1124 Ipv4L3Protocol::RouteInputError (Ptr<const Packet> p, const Ipv4Header & ipHeade r, Socket::SocketErrno sockErrno) | 1111 Ipv4L3Protocol::RouteInputError (Ptr<const Packet> p, const Ipv4Header & ipHeade r, Socket::SocketErrno sockErrno) |
1125 { | 1112 { |
1126 NS_LOG_FUNCTION (this << p << ipHeader << sockErrno); | 1113 NS_LOG_FUNCTION (this << p << ipHeader << sockErrno); |
1127 NS_LOG_LOGIC ("Route input failure-- dropping packet to " << ipHeader << " wit h errno " << sockErrno); | 1114 NS_LOG_LOGIC ("Route input failure-- dropping packet to " << ipHeader << " wit h errno " << sockErrno); |
1128 m_dropTrace (ipHeader, p, DROP_ROUTE_ERROR, m_node->GetObject<Ipv4> (), 0); | 1115 m_dropTrace (ipHeader, p, DROP_ROUTE_ERROR, m_node->GetObject<Ipv4> (), 0); |
1129 } | 1116 } |
1130 | 1117 |
1131 void | 1118 void |
1132 Ipv4L3Protocol::DoFragmentation (Ptr<Packet> packet, uint32_t outIfaceMtu, std:: list<Ptr<Packet> >& listFragments) | 1119 Ipv4L3Protocol::DoFragmentation (Ptr<Packet> packet, uint32_t outIfaceMtu, std:: list<Ptr<Packet> >& listFragments) |
1133 { | 1120 { |
1134 // BEWARE: here we do assume that the header options are not present. | 1121 // BEWARE: here we do assume that the header options are not present. |
1135 // a much more complex handling is necessary in case there are options. | 1122 // a much more complex handling is necessary in case there are options. |
1136 // If (when) IPv4 option headers will be implemented, the following code shall be changed. | 1123 // If (when) IPv4 option headers will be implemented, the following code shall be changed. |
1137 // Of course also the reassemby code shall be changed as well. | 1124 // Of course also the reassemby code shall be changed as well. |
1138 | 1125 |
1139 NS_LOG_FUNCTION (this << *packet << " - MTU: " << outIfaceMtu); | 1126 NS_LOG_FUNCTION (this << *packet << " - MTU: " << outIfaceMtu); |
1140 | 1127 |
1141 Ptr<Packet> p = packet->Copy (); | 1128 Ptr<Packet> p = packet->Copy (); |
1142 | 1129 |
1143 Ipv4Header ipv4Header; | 1130 Ipv4Header ipv4Header; |
1144 p->RemoveHeader (ipv4Header); | 1131 p->RemoveHeader (ipv4Header); |
1132 | |
1133 NS_ASSERT_MSG( (ipv4Header.GetSerializedSize() == 5*4), | |
1134 "IPv4 fragmentation implementation only works without option he aders." ); | |
1145 | 1135 |
1146 uint16_t offset = 0; | 1136 uint16_t offset = 0; |
1147 bool moreFragment = true; | 1137 bool moreFragment = true; |
1148 uint32_t currentFragmentablePartSize = 0; | 1138 uint32_t currentFragmentablePartSize = 0; |
1149 | 1139 |
1150 // IPv4 fragments are all 8 bytes aligned but the last. | 1140 // IPv4 fragments are all 8 bytes aligned but the last. |
1151 // The IP payload size is: | 1141 // The IP payload size is: |
1152 // floor( ( outIfaceMtu - ipv4Header.GetSerializedSize() ) /8 ) *8 | 1142 // floor( ( outIfaceMtu - ipv4Header.GetSerializedSize() ) /8 ) *8 |
1153 uint32_t fragmentSize = (outIfaceMtu - ipv4Header.GetSerializedSize () ) & ~ui nt32_t (0x7); | 1143 uint32_t fragmentSize = (outIfaceMtu - ipv4Header.GetSerializedSize () ) & ~ui nt32_t (0x7); |
1154 | 1144 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1197 | 1187 |
1198 return; | 1188 return; |
1199 } | 1189 } |
1200 | 1190 |
1201 bool | 1191 bool |
1202 Ipv4L3Protocol::ProcessFragment (Ptr<Packet>& packet, Ipv4Header& ipHeader, uint 32_t iif) | 1192 Ipv4L3Protocol::ProcessFragment (Ptr<Packet>& packet, Ipv4Header& ipHeader, uint 32_t iif) |
1203 { | 1193 { |
1204 NS_LOG_FUNCTION (this << packet << " " << ipHeader << " " << iif); | 1194 NS_LOG_FUNCTION (this << packet << " " << ipHeader << " " << iif); |
1205 | 1195 |
1206 uint64_t addressCombination = uint64_t (ipHeader.GetSource ().Get ()) << 32 & uint64_t (ipHeader.GetDestination ().Get ()); | 1196 uint64_t addressCombination = uint64_t (ipHeader.GetSource ().Get ()) << 32 & uint64_t (ipHeader.GetDestination ().Get ()); |
1207 uint32_t idProto = uint32_t (ipHeader.GetIdentification ()) << 16 & uint32_t ( ipHeader.GetProtocol ()); | 1197 uint32_t idProto = uint32_t (ipHeader.GetIdentification ()) << 16 & uint32_t ( ipHeader.GetProtocol ()); |
Vedran Miletić
2011/06/24 15:51:05
Wouldn't it be better to use std::pair here (both
Tommaso Pecorella
2011/06/24 19:49:00
Could be, but the key is a Pair already and those
| |
1208 std::pair<uint64_t, uint32_t> key; | 1198 std::pair<uint64_t, uint32_t> key; |
1209 bool ret = false; | 1199 bool ret = false; |
1210 Ptr<Packet> p = packet->Copy (); | 1200 Ptr<Packet> p = packet->Copy (); |
1211 | 1201 |
1212 key.first = addressCombination; | 1202 key.first = addressCombination; |
1213 key.second = idProto; | 1203 key.second = idProto; |
1214 | 1204 |
1215 Ptr<Fragments> fragments; | 1205 Ptr<Fragments> fragments; |
1216 | 1206 |
1217 MapFragments_t::iterator it = m_fragments.find (key); | 1207 MapFragments_t::iterator it = m_fragments.find (key); |
1218 if (it == m_fragments.end ()) | 1208 if (it == m_fragments.end ()) |
1219 { | 1209 { |
1220 fragments = Create<Fragments> (); | 1210 fragments = Create<Fragments> (); |
1221 m_fragments.insert (std::make_pair (key, fragments)); | 1211 m_fragments.insert (std::make_pair (key, fragments)); |
1222 m_fragmentsTimers[key] = Simulator::Schedule (m_waitFragmentsTimeout, | 1212 m_fragmentsTimers[key] = Simulator::Schedule (m_fragmentExpirationTimeout, |
1223 &Ipv4L3Protocol::HandleFragm entsTimeout, this, | 1213 &Ipv4L3Protocol::HandleFragm entsTimeout, this, |
1224 key, ipHeader, iif); | 1214 key, ipHeader, iif); |
1225 } | 1215 } |
1226 else | 1216 else |
1227 { | 1217 { |
1228 fragments = it->second; | 1218 fragments = it->second; |
1229 } | 1219 } |
1230 | 1220 |
1231 NS_LOG_LOGIC ("Adding fragment - Size: " << packet->GetSize ( ) << " - Offset: " << (ipHeader.GetFragmentOffset ()) ); | 1221 NS_LOG_LOGIC ("Adding fragment - Size: " << packet->GetSize ( ) << " - Offset: " << (ipHeader.GetFragmentOffset ()) ); |
1232 | 1222 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1375 NS_LOG_LOGIC ("Adding: " << *(it->first) ); | 1365 NS_LOG_LOGIC ("Adding: " << *(it->first) ); |
1376 p->AddAtEnd (it->first); | 1366 p->AddAtEnd (it->first); |
1377 } | 1367 } |
1378 lastEndOffset = p->GetSize (); | 1368 lastEndOffset = p->GetSize (); |
1379 } | 1369 } |
1380 | 1370 |
1381 return p; | 1371 return p; |
1382 } | 1372 } |
1383 | 1373 |
1384 void | 1374 void |
1385 Ipv4L3Protocol::HandleFragmentsTimeout (std::pair<uint64_t, uint32_t> key, Ipv4H eader & ipHeader, uint32_t iif) | 1375 Ipv4L3Protocol::HandleFragmentsTimeout (std::pair<uint64_t, uint32_t> key, Ipv4H eader & ipHeader, uint32_t iif) |
Vedran Miletić
2011/06/24 15:51:05
I don't understand when does this get called.
Tommaso Pecorella
2011/06/24 19:49:00
In Ipv4L3Protocol::ProcessFragment:
m_fragme
| |
1386 { | 1376 { |
1387 NS_LOG_FUNCTION (this); | 1377 NS_LOG_FUNCTION (this); |
1388 | 1378 |
1389 MapFragments_t::iterator it = m_fragments.find (key); | 1379 MapFragments_t::iterator it = m_fragments.find (key); |
1390 Ptr<Packet> packet = it->second->GetPartialPacket (); | 1380 Ptr<Packet> packet = it->second->GetPartialPacket (); |
1391 | 1381 |
1392 // if we have at least 8 bytes, we can send an ICMP. | 1382 // if we have at least 8 bytes, we can send an ICMP. |
1393 if ( packet->GetSize () > 8 ) | 1383 if ( packet->GetSize () > 8 ) |
1394 { | 1384 { |
1395 Ptr<Icmpv4L4Protocol> icmp = GetIcmp (); | 1385 Ptr<Icmpv4L4Protocol> icmp = GetIcmp (); |
1396 icmp->SendTimeExceededTtl (ipHeader, packet); | 1386 icmp->SendTimeExceededTtl (ipHeader, packet); |
1397 } | 1387 } |
1398 m_dropTrace (ipHeader, packet, DROP_FRAGMENT_TIMEOUT, m_node->GetObject<Ipv4> (), iif); | 1388 m_dropTrace (ipHeader, packet, DROP_FRAGMENT_TIMEOUT, m_node->GetObject<Ipv4> (), iif); |
1399 | 1389 |
1400 // clear the buffers | 1390 // clear the buffers |
1401 it->second = 0; | 1391 it->second = 0; |
1402 | 1392 |
1403 m_fragments.erase (key); | 1393 m_fragments.erase (key); |
1404 m_fragmentsTimers.erase (key); | 1394 m_fragmentsTimers.erase (key); |
1405 } | 1395 } |
1406 | 1396 |
1407 } //namespace ns3 | 1397 } //namespace ns3 |
LEFT | RIGHT |