A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ndisc-cache.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007-2009 Strasbourg University
4  *
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
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
19  */
20 
21 #ifndef NDISC_CACHE_H
22 #define NDISC_CACHE_H
23 
24 #include <stdint.h>
25 
26 #include <list>
27 
28 #include "ns3/packet.h"
29 #include "ns3/nstime.h"
30 #include "ns3/net-device.h"
31 #include "ns3/ipv6-address.h"
32 #include "ns3/ptr.h"
33 #include "ns3/timer.h"
34 #include "ns3/sgi-hashmap.h"
35 
36 namespace ns3
37 {
38 
39 class NetDevice;
40 class Ipv6Interface;
41 
46 class NdiscCache : public Object
47 {
48 public:
49  class Entry;
50 
55  static TypeId GetTypeId ();
56 
60  static const uint32_t DEFAULT_UNRES_QLEN = 3;
61 
65  NdiscCache ();
66 
70  ~NdiscCache ();
71 
76  Ptr<NetDevice> GetDevice () const;
77 
82 
89 
96 
101  void Remove (NdiscCache::Entry* entry);
102 
106  void Flush ();
107 
112  void SetUnresQlen (uint32_t unresQlen);
113 
118  uint32_t GetUnresQlen ();
119 
125  void SetDevice (Ptr<NetDevice> device, Ptr<Ipv6Interface> interface);
126 
131  class Entry
132  {
133 public:
138  Entry (NdiscCache* nd);
139 
144  void MarkIncomplete (Ptr<Packet> p);
145 
151  std::list<Ptr<Packet> > MarkReachable (Address mac);
152 
156  void MarkProbe ();
157 
163  std::list<Ptr<Packet> > MarkStale (Address mac);
164 
168  void MarkStale ();
169 
173  void MarkReachable ();
174 
178  void MarkDelay ();
179 
184  void AddWaitingPacket (Ptr<Packet> p);
185 
189  void ClearWaitingPacket ();
190 
195  bool IsStale () const;
196 
201  bool IsReachable () const;
202 
207  bool IsDelay () const;
208 
213  bool IsIncomplete () const;
214 
219  bool IsProbe () const;
220 
225  Address GetMacAddress () const;
226 
231  void SetMacAddress (Address mac);
232 
237  bool IsRouter () const;
238 
243  void SetRouter (bool router);
244 
249  uint8_t GetNSRetransmit () const;
250 
254  void IncNSRetransmit ();
255 
259  void ResetNSRetransmit ();
260 
266 
271 
275  void StartReachableTimer ();
276 
280  void StopReachableTimer ();
281 
285  void StartRetransmitTimer ();
286 
290  void StopRetransmitTimer ();
291 
295  void StartProbeTimer ();
296 
300  void StopProbeTimer ();
301 
305  void StartDelayTimer ();
306 
310  void StopDelayTimer ();
311 
315  void FunctionReachableTimeout ();
316 
323 
327  void FunctionProbeTimeout ();
328 
332  void FunctionDelayTimeout ();
333 
338  void SetIpv6Address (Ipv6Address ipv6Address);
339 
340 private:
345 
350  {
356  };
357 
362 
367 
372 
376  std::list<Ptr<Packet> > m_waiting;
377 
381  bool m_router;
382 
387 
392 
397 
402 
407 
411  uint8_t m_nsRetransmit;
412  };
413 
414 private:
415  typedef sgi::hash_map<Ipv6Address, NdiscCache::Entry *, Ipv6AddressHash> Cache;
416  typedef sgi::hash_map<Ipv6Address, NdiscCache::Entry *, Ipv6AddressHash>::iterator CacheI;
417 
422  NdiscCache (NdiscCache const &a);
423 
428  NdiscCache& operator= (NdiscCache const &a);
429 
433  void DoDispose ();
434 
439 
444 
449 
453  uint32_t m_unresQlen;
454 };
455 
456 } /* namespace ns3 */
457 
458 #endif /* NDISC_CACHE_H */
459