A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ipv6-extension.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: David Gross <gdavid.devel@gmail.com>
19  */
20 
21 #ifndef IPV6_EXTENSION_H
22 #define IPV6_EXTENSION_H
23 
24 #include <map>
25 #include <list>
26 
27 #include "ns3/object.h"
28 #include "ns3/node.h"
29 #include "ns3/ptr.h"
30 #include "ipv6-interface.h"
31 #include "ns3/ipv6-header.h"
32 #include "ns3/buffer.h"
33 #include "ns3/packet.h"
34 #include "ns3/random-variable-stream.h"
35 #include "ns3/ipv6-address.h"
36 #include "ns3/ipv6-l3-protocol.h"
37 #include "ns3/traced-callback.h"
38 
39 
40 namespace ns3 {
41 
48 class Ipv6Extension : public Object
49 {
50 public:
55  static TypeId GetTypeId ();
56 
60  Ipv6Extension ();
61 
65  virtual ~Ipv6Extension ();
66 
71  void SetNode (Ptr<Node> node);
72 
77  Ptr<Node> GetNode () const;
78 
83  virtual uint8_t GetExtensionNumber () const = 0;
84 
99  virtual uint8_t Process (Ptr<Packet>& packet,
100  uint8_t offset,
101  Ipv6Header const& ipv6Header,
102  Ipv6Address dst,
103  uint8_t *nextHeader,
104  bool& stopProcessing,
105  bool& isDropped,
106  Ipv6L3Protocol::DropReason& dropReason) = 0;
107 
123  virtual uint8_t ProcessOptions (Ptr<Packet>& packet,
124  uint8_t offset,
125  uint8_t length,
126  Ipv6Header const& ipv6Header,
127  Ipv6Address dst,
128  uint8_t *nextHeader,
129  bool& stopProcessing,
130  bool& isDropped,
131  Ipv6L3Protocol::DropReason& dropReason
132  );
133 
142  int64_t AssignStreams (int64_t stream);
143 
144 protected:
149 
150 private:
155 };
156 
162 {
163 public:
167  static const uint8_t EXT_NUMBER = 0;
168 
173  static TypeId GetTypeId ();
174 
179 
184 
189  virtual uint8_t GetExtensionNumber () const;
190 
191  virtual uint8_t Process (Ptr<Packet>& packet,
192  uint8_t offset,
193  Ipv6Header const& ipv6Header,
194  Ipv6Address dst,
195  uint8_t *nextHeader,
196  bool& stopProcessing,
197  bool& isDropped,
198  Ipv6L3Protocol::DropReason& dropReason);
199 };
200 
206 {
207 public:
211  static const uint8_t EXT_NUMBER = 60;
212 
217  static TypeId GetTypeId ();
218 
223 
228 
233  virtual uint8_t GetExtensionNumber () const;
234 
235  virtual uint8_t Process (Ptr<Packet>& packet,
236  uint8_t offset,
237  Ipv6Header const& ipv6Header,
238  Ipv6Address dst,
239  uint8_t *nextHeader,
240  bool& stopProcessing,
241  bool& isDropped,
242  Ipv6L3Protocol::DropReason& dropReason);
243 };
244 
250 {
251 public:
255  static const uint8_t EXT_NUMBER = 44;
256 
261  static TypeId GetTypeId ();
262 
267 
272 
277  virtual uint8_t GetExtensionNumber () const;
278 
279  virtual uint8_t Process (Ptr<Packet>& packet,
280  uint8_t offset,
281  Ipv6Header const& ipv6Header,
282  Ipv6Address dst,
283  uint8_t *nextHeader,
284  bool& stopProcessing,
285  bool& isDropped,
286  Ipv6L3Protocol::DropReason& dropReason);
287 
294  void GetFragments (Ptr<Packet> packet, uint32_t fragmentSize, std::list<Ptr<Packet> >& listFragments);
295 
296 protected:
300  virtual void DoDispose ();
301 
302 private:
307  class Fragments : public SimpleRefCount<Fragments>
308  {
309 public:
313  Fragments ();
314 
318  ~Fragments ();
319 
326  void AddFragment (Ptr<Packet> fragment, uint16_t fragmentOffset, bool moreFragment);
327 
332  void SetUnfragmentablePart (Ptr<Packet> unfragmentablePart);
333 
338  bool IsEntire () const;
339 
344  Ptr<Packet> GetPacket () const;
345 
350  Ptr<Packet> GetPartialPacket () const;
351 
355  void SetTimeoutEventId (EventId event);
356 
360  void CancelTimeout ();
361 
362 private:
367 
371  std::list<std::pair<Ptr<Packet>, uint16_t> > m_packetFragments;
372 
377 
382  };
383 
389  void HandleFragmentsTimeout (std::pair<Ipv6Address, uint32_t> key, Ipv6Header ipHeader);
390 
395  Ptr<Packet> GetPartialPacket () const;
396 
400  void SetTimeoutEventId (EventId event);
401 
405  void CancelTimeout ();
406 
410  typedef std::map<std::pair<Ipv6Address, uint32_t>, Ptr<Fragments> > MapFragments_t;
411 
416 };
417 
425 {
426 public:
430  static const uint8_t EXT_NUMBER = 43;
431 
436  static TypeId GetTypeId ();
437 
442 
447 
452  virtual uint8_t GetExtensionNumber () const;
453 
458  virtual uint8_t GetTypeRouting () const;
459 
460  virtual uint8_t Process (Ptr<Packet>& packet,
461  uint8_t offset,
462  Ipv6Header const& ipv6Header,
463  Ipv6Address dst,
464  uint8_t *nextHeader,
465  bool& stopProcessing,
466  bool& isDropped,
467  Ipv6L3Protocol::DropReason& dropReason);
468 };
469 
475 {
476 public:
481  static TypeId GetTypeId ();
482 
487 
491  virtual ~Ipv6ExtensionRoutingDemux ();
492 
497  void SetNode (Ptr<Node> node);
498 
503  void Insert (Ptr<Ipv6ExtensionRouting> extensionRouting);
504 
510  Ptr<Ipv6ExtensionRouting> GetExtensionRouting (uint8_t typeRouting);
511 
516  void Remove (Ptr<Ipv6ExtensionRouting> extensionRouting);
517 
518 protected:
522  virtual void DoDispose ();
523 
524 private:
528  typedef std::list<Ptr<Ipv6ExtensionRouting> > Ipv6ExtensionRoutingList_t;
529 
534 
539 };
540 
546 {
547 public:
551  static const uint8_t TYPE_ROUTING = 0;
552 
557  static TypeId GetTypeId ();
558 
563 
568 
573  virtual uint8_t GetTypeRouting () const;
574 
575  virtual uint8_t Process (Ptr<Packet>& packet,
576  uint8_t offset,
577  Ipv6Header const& ipv6Header,
578  Ipv6Address dst,
579  uint8_t *nextHeader,
580  bool& stopProcessing,
581  bool& isDropped,
582  Ipv6L3Protocol::DropReason& dropReason);
583 };
584 
590 {
591 public:
595  static const uint8_t EXT_NUMBER = 50;
596 
601  static TypeId GetTypeId ();
602 
606  Ipv6ExtensionESP ();
607 
612 
617  virtual uint8_t GetExtensionNumber () const;
618 
619  virtual uint8_t Process (Ptr<Packet>& packet,
620  uint8_t offset,
621  Ipv6Header const& ipv6Header,
622  Ipv6Address dst,
623  uint8_t *nextHeader,
624  bool& stopProcessing,
625  bool& isDropped,
626  Ipv6L3Protocol::DropReason& dropReason);
627 };
628 
634 {
635 public:
639  static const uint8_t EXT_NUMBER = 51;
640 
645  static TypeId GetTypeId ();
646 
650  Ipv6ExtensionAH ();
651 
655  ~Ipv6ExtensionAH ();
656 
661  virtual uint8_t GetExtensionNumber () const;
662 
663  virtual uint8_t Process (Ptr<Packet>& packet,
664  uint8_t offset,
665  Ipv6Header const& ipv6Header,
666  Ipv6Address dst,
667  uint8_t *nextHeader,
668  bool& stopProcessing,
669  bool& isDropped,
670  Ipv6L3Protocol::DropReason& dropReason);
671 };
672 
673 } /* namespace ns3 */
674 
675 #endif /* IPV6_EXTENSION_H */
676 
void GetFragments(Ptr< Packet > packet, uint32_t fragmentSize, std::list< Ptr< Packet > > &listFragments)
Fragment a packet.
Ptr< UniformRandomVariable > m_uvar
Provides uniform random variables.
Doxygen introspection did not find any typical Config paths.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
virtual uint8_t Process(Ptr< Packet > &packet, uint8_t offset, Ipv6Header const &ipv6Header, Ipv6Address dst, uint8_t *nextHeader, bool &stopProcessing, bool &isDropped, Ipv6L3Protocol::DropReason &dropReason)
Process method Called from Ipv6L3Protocol::Receive.
Ipv6ExtensionLooseRouting()
Constructor.
Doxygen introspection did not find any typical Config paths.
Definition: ipv6-header.h:33
virtual void DoDispose()
Dispose this object.
Ptr< Packet > GetPartialPacket() const
Get the packet parts so far received.
void Insert(Ptr< Ipv6ExtensionRouting > extensionRouting)
Insert a new IPv6 Routing Extension.
static const uint8_t EXT_NUMBER
Fragmentation extension number.
void SetTimeoutEventId(EventId event)
Set the Timeout EventId.
void SetNode(Ptr< Node > node)
Set the node.
virtual void DoDispose()
Dispose this object.
virtual uint8_t GetExtensionNumber() const
Get the extension number.
static TypeId GetTypeId()
Get the type identificator.
virtual uint8_t GetExtensionNumber() const
Get the extension number.
static const uint8_t TYPE_ROUTING
Routing type.
virtual uint8_t Process(Ptr< Packet > &packet, uint8_t offset, Ipv6Header const &ipv6Header, Ipv6Address dst, uint8_t *nextHeader, bool &stopProcessing, bool &isDropped, Ipv6L3Protocol::DropReason &dropReason)
Process method Called from Ipv6L3Protocol::Receive.
static TypeId GetTypeId()
Get the type identificator.
virtual ~Ipv6ExtensionRoutingDemux()
Destructor.
Ipv6ExtensionRoutingDemux()
Constructor.
Doxygen introspection did not find any typical Config paths.
Ipv6ExtensionFragment()
Constructor.
virtual uint8_t GetExtensionNumber() const
Get the extension number.
Doxygen introspection did not find any typical Config paths.
void CancelTimeout()
Cancel the timeout event.
static TypeId GetTypeId()
Get the type identificator.
~Ipv6ExtensionHopByHop()
Destructor.
virtual uint8_t Process(Ptr< Packet > &packet, uint8_t offset, Ipv6Header const &ipv6Header, Ipv6Address dst, uint8_t *nextHeader, bool &stopProcessing, bool &isDropped, Ipv6L3Protocol::DropReason &dropReason)
Process method Called from Ipv6L3Protocol::Receive.
virtual uint8_t Process(Ptr< Packet > &packet, uint8_t offset, Ipv6Header const &ipv6Header, Ipv6Address dst, uint8_t *nextHeader, bool &stopProcessing, bool &isDropped, Ipv6L3Protocol::DropReason &dropReason)=0
Process method Called from Ipv6L3Protocol::Receive.
void SetTimeoutEventId(EventId event)
Set the Timeout EventId.
Ipv6ExtensionHopByHop()
Constructor.
virtual uint8_t Process(Ptr< Packet > &packet, uint8_t offset, Ipv6Header const &ipv6Header, Ipv6Address dst, uint8_t *nextHeader, bool &stopProcessing, bool &isDropped, Ipv6L3Protocol::DropReason &dropReason)
Process method Called from Ipv6L3Protocol::Receive.
virtual uint8_t Process(Ptr< Packet > &packet, uint8_t offset, Ipv6Header const &ipv6Header, Ipv6Address dst, uint8_t *nextHeader, bool &stopProcessing, bool &isDropped, Ipv6L3Protocol::DropReason &dropReason)
Process method Called from Ipv6L3Protocol::Receive.
std::list< Ptr< Ipv6ExtensionRouting > > Ipv6ExtensionRoutingList_t
Container for the extension routing.
Ptr< Packet > GetPacket() const
Get the entire packet.
Ptr< Packet > m_unfragmentable
The unfragmentable part.
Doxygen introspection did not find any typical Config paths.
bool m_moreFragment
If other fragments will be sent.
~Ipv6ExtensionFragment()
Destructor.
void CancelTimeout()
Cancel the timeout event.
virtual uint8_t Process(Ptr< Packet > &packet, uint8_t offset, Ipv6Header const &ipv6Header, Ipv6Address dst, uint8_t *nextHeader, bool &stopProcessing, bool &isDropped, Ipv6L3Protocol::DropReason &dropReason)
Process method Called from Ipv6L3Protocol::Receive.
~Ipv6ExtensionRouting()
Destructor.
Ptr< Node > m_node
The node.
static TypeId GetTypeId()
Get the type identificator.
virtual uint8_t Process(Ptr< Packet > &packet, uint8_t offset, Ipv6Header const &ipv6Header, Ipv6Address dst, uint8_t *nextHeader, bool &stopProcessing, bool &isDropped, Ipv6L3Protocol::DropReason &dropReason)
Process method Called from Ipv6L3Protocol::Receive.
Ipv6ExtensionDestination()
Constructor.
Doxygen introspection did not find any typical Config paths.
#define list
void SetUnfragmentablePart(Ptr< Packet > unfragmentablePart)
Set the unfragmentable part of the packet.
bool IsEntire() const
If all fragments have been added.
Doxygen introspection did not find any typical Config paths.
Ptr< Node > GetNode() const
Get the node.
void Remove(Ptr< Ipv6ExtensionRouting > extensionRouting)
Remove a routing extension from this demux.
void AddFragment(Ptr< Packet > fragment, uint16_t fragmentOffset, bool moreFragment)
Add a fragment.
void SetNode(Ptr< Node > node)
Set the node.
virtual uint8_t GetExtensionNumber() const
Get the extension number.
static TypeId GetTypeId()
Get the type identificator.
MapFragments_t m_fragments
The hash of fragmented packets.
static TypeId GetTypeId()
The interface ID.
static TypeId GetTypeId()
Get the type identificator.
Ptr< Ipv6ExtensionRouting > GetExtensionRouting(uint8_t typeRouting)
Get the routing extension corresponding to typeRouting.
~Ipv6ExtensionESP()
Destructor.
Ipv6ExtensionAH()
Constructor.
static TypeId GetTypeId()
Get the type identificator.
Doxygen introspection did not find any typical Config paths.
virtual uint8_t GetExtensionNumber() const =0
Get the extension number.
std::map< std::pair< Ipv6Address, uint32_t >, Ptr< Fragments > > MapFragments_t
Container for the packet fragments.
static const uint8_t EXT_NUMBER
Hop-by-hop extension number.
Ipv6Extension()
Constructor.
Doxygen introspection did not find any typical Config paths.
EventId m_timeoutEventId
Timeout handler event.
Describes an IPv6 address.
Definition: ipv6-address.h:46
virtual uint8_t GetTypeRouting() const
Get the type of routing.
an identifier for simulation events.
Definition: event-id.h:46
Ipv6ExtensionRouting()
Constructor.
virtual uint8_t GetExtensionNumber() const
Get the extension number.
virtual uint8_t GetExtensionNumber() const
Get the extension number.
virtual uint8_t ProcessOptions(Ptr< Packet > &packet, uint8_t offset, uint8_t length, Ipv6Header const &ipv6Header, Ipv6Address dst, uint8_t *nextHeader, bool &stopProcessing, bool &isDropped, Ipv6L3Protocol::DropReason &dropReason)
Process options Called by implementing classes to process the options.
virtual uint8_t GetTypeRouting() const
Get the type of routing.
static const uint8_t EXT_NUMBER
ESP extension number.
Ipv6ExtensionRoutingList_t m_extensionsRouting
List of IPv6 Routing Extensions supported.
std::list< std::pair< Ptr< Packet >, uint16_t > > m_packetFragments
The current fragments.
Ipv6ExtensionESP()
Constructor.
void HandleFragmentsTimeout(std::pair< Ipv6Address, uint32_t > key, Ipv6Header ipHeader)
Process the timeout for packet fragments.
a base class which provides memory management and object aggregation
Definition: object.h:64
static const uint8_t EXT_NUMBER
Destination extension number.
Ptr< Node > m_node
The node.
static const uint8_t EXT_NUMBER
Routing extension number.
A template-based reference counting class.
a unique identifier for an interface.
Definition: type-id.h:49
static TypeId GetTypeId()
Get the type identificator.
static const uint8_t EXT_NUMBER
AH extension number.
~Ipv6ExtensionAH()
Destructor.
Ptr< Packet > GetPartialPacket() const
Get the packet parts so far received.
DropReason
Reason why a packet has been dropped.
virtual ~Ipv6Extension()
Destructor.
Doxygen introspection did not find any typical Config paths.