A Discrete-Event Network Simulator
API
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 
54 class Ipv6Extension : public Object
55 {
56 public:
61  static TypeId GetTypeId ();
62 
66  Ipv6Extension ();
67 
71  virtual ~Ipv6Extension ();
72 
77  void SetNode (Ptr<Node> node);
78 
83  Ptr<Node> GetNode () const;
84 
89  virtual uint8_t GetExtensionNumber () const = 0;
90 
105  virtual uint8_t Process (Ptr<Packet>& packet,
106  uint8_t offset,
107  Ipv6Header const& ipv6Header,
108  Ipv6Address dst,
109  uint8_t *nextHeader,
110  bool& stopProcessing,
111  bool& isDropped,
112  Ipv6L3Protocol::DropReason& dropReason) = 0;
113 
129  virtual uint8_t ProcessOptions (Ptr<Packet>& packet,
130  uint8_t offset,
131  uint8_t length,
132  Ipv6Header const& ipv6Header,
133  Ipv6Address dst,
134  uint8_t *nextHeader,
135  bool& stopProcessing,
136  bool& isDropped,
137  Ipv6L3Protocol::DropReason& dropReason
138  );
139 
148  int64_t AssignStreams (int64_t stream);
149 
150 protected:
155 
156 private:
161 };
162 
169 {
170 public:
174  static const uint8_t EXT_NUMBER = 0;
175 
180  static TypeId GetTypeId ();
181 
186 
191 
196  virtual uint8_t GetExtensionNumber () const;
197 
198  virtual uint8_t Process (Ptr<Packet>& packet,
199  uint8_t offset,
200  Ipv6Header const& ipv6Header,
201  Ipv6Address dst,
202  uint8_t *nextHeader,
203  bool& stopProcessing,
204  bool& isDropped,
205  Ipv6L3Protocol::DropReason& dropReason);
206 };
207 
214 {
215 public:
219  static const uint8_t EXT_NUMBER = 60;
220 
225  static TypeId GetTypeId ();
226 
231 
236 
241  virtual uint8_t GetExtensionNumber () const;
242 
243  virtual uint8_t Process (Ptr<Packet>& packet,
244  uint8_t offset,
245  Ipv6Header const& ipv6Header,
246  Ipv6Address dst,
247  uint8_t *nextHeader,
248  bool& stopProcessing,
249  bool& isDropped,
250  Ipv6L3Protocol::DropReason& dropReason);
251 };
252 
259 {
260 public:
264  static const uint8_t EXT_NUMBER = 44;
265 
270  static TypeId GetTypeId ();
271 
276 
281 
286  virtual uint8_t GetExtensionNumber () const;
287 
288  virtual uint8_t Process (Ptr<Packet>& packet,
289  uint8_t offset,
290  Ipv6Header const& ipv6Header,
291  Ipv6Address dst,
292  uint8_t *nextHeader,
293  bool& stopProcessing,
294  bool& isDropped,
295  Ipv6L3Protocol::DropReason& dropReason);
296 
300  typedef std::pair<Ptr<Packet>, Ipv6Header> Ipv6PayloadHeaderPair;
301 
310  void GetFragments (Ptr<Packet> packet, Ipv6Header ipv6Header, uint32_t fragmentSize, std::list<Ipv6PayloadHeaderPair>& listFragments);
311 
312 protected:
316  virtual void DoDispose ();
317 
318 private:
324  class Fragments : public SimpleRefCount<Fragments>
325  {
326 public:
330  Fragments ();
331 
335  ~Fragments ();
336 
343  void AddFragment (Ptr<Packet> fragment, uint16_t fragmentOffset, bool moreFragment);
344 
349  void SetUnfragmentablePart (Ptr<Packet> unfragmentablePart);
350 
355  bool IsEntire () const;
356 
361  Ptr<Packet> GetPacket () const;
362 
367  Ptr<Packet> GetPartialPacket () const;
368 
373  void SetTimeoutEventId (EventId event);
374 
378  void CancelTimeout ();
379 
380 private:
385 
389  std::list<std::pair<Ptr<Packet>, uint16_t> > m_packetFragments;
390 
395 
400  };
401 
407  void HandleFragmentsTimeout (std::pair<Ipv6Address, uint32_t> key, Ipv6Header ipHeader);
408 
413  Ptr<Packet> GetPartialPacket () const;
414 
419  void SetTimeoutEventId (EventId event);
420 
424  void CancelTimeout ();
425 
429  typedef std::map<std::pair<Ipv6Address, uint32_t>, Ptr<Fragments> > MapFragments_t;
430 
435 };
436 
446 {
447 public:
451  static const uint8_t EXT_NUMBER = 43;
452 
457  static TypeId GetTypeId ();
458 
463 
468 
473  virtual uint8_t GetExtensionNumber () const;
474 
479  virtual uint8_t GetTypeRouting () const;
480 
481  virtual uint8_t Process (Ptr<Packet>& packet,
482  uint8_t offset,
483  Ipv6Header const& ipv6Header,
484  Ipv6Address dst,
485  uint8_t *nextHeader,
486  bool& stopProcessing,
487  bool& isDropped,
488  Ipv6L3Protocol::DropReason& dropReason);
489 };
490 
497 {
498 public:
503  static TypeId GetTypeId ();
504 
509 
513  virtual ~Ipv6ExtensionRoutingDemux ();
514 
519  void SetNode (Ptr<Node> node);
520 
525  void Insert (Ptr<Ipv6ExtensionRouting> extensionRouting);
526 
532  Ptr<Ipv6ExtensionRouting> GetExtensionRouting (uint8_t typeRouting);
533 
538  void Remove (Ptr<Ipv6ExtensionRouting> extensionRouting);
539 
540 protected:
544  virtual void DoDispose ();
545 
546 private:
550  typedef std::list<Ptr<Ipv6ExtensionRouting> > Ipv6ExtensionRoutingList_t;
551 
556 
561 };
562 
569 {
570 public:
574  static const uint8_t TYPE_ROUTING = 0;
575 
580  static TypeId GetTypeId ();
581 
586 
591 
596  virtual uint8_t GetTypeRouting () const;
597 
598  virtual uint8_t Process (Ptr<Packet>& packet,
599  uint8_t offset,
600  Ipv6Header const& ipv6Header,
601  Ipv6Address dst,
602  uint8_t *nextHeader,
603  bool& stopProcessing,
604  bool& isDropped,
605  Ipv6L3Protocol::DropReason& dropReason);
606 };
607 
614 {
615 public:
619  static const uint8_t EXT_NUMBER = 50;
620 
625  static TypeId GetTypeId ();
626 
630  Ipv6ExtensionESP ();
631 
636 
641  virtual uint8_t GetExtensionNumber () const;
642 
643  virtual uint8_t Process (Ptr<Packet>& packet,
644  uint8_t offset,
645  Ipv6Header const& ipv6Header,
646  Ipv6Address dst,
647  uint8_t *nextHeader,
648  bool& stopProcessing,
649  bool& isDropped,
650  Ipv6L3Protocol::DropReason& dropReason);
651 };
652 
659 {
660 public:
664  static const uint8_t EXT_NUMBER = 51;
665 
670  static TypeId GetTypeId ();
671 
675  Ipv6ExtensionAH ();
676 
680  ~Ipv6ExtensionAH ();
681 
686  virtual uint8_t GetExtensionNumber () const;
687 
688  virtual uint8_t Process (Ptr<Packet>& packet,
689  uint8_t offset,
690  Ipv6Header const& ipv6Header,
691  Ipv6Address dst,
692  uint8_t *nextHeader,
693  bool& stopProcessing,
694  bool& isDropped,
695  Ipv6L3Protocol::DropReason& dropReason);
696 };
697 
698 } /* namespace ns3 */
699 
700 #endif /* IPV6_EXTENSION_H */
701 
Ptr< UniformRandomVariable > m_uvar
Provides uniform random variables.
This class stores the fragments of a packet waiting to be rebuilt.
IPv6 Extension base If you want to implement a new IPv6 extension, all you have to do is implement a ...
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.
Packet header for IPv6.
Definition: ipv6-header.h:34
virtual void DoDispose()
Dispose this object.
void Insert(Ptr< Ipv6ExtensionRouting > extensionRouting)
Insert a new IPv6 Routing Extension.
Ptr< Packet > GetPartialPacket() const
Get the packet parts so far received.
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.
static TypeId GetTypeId()
Get the type identificator.
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.
void GetFragments(Ptr< Packet > packet, Ipv6Header ipv6Header, uint32_t fragmentSize, std::list< Ipv6PayloadHeaderPair > &listFragments)
Fragment a packet.
virtual ~Ipv6ExtensionRoutingDemux()
Destructor.
Ipv6ExtensionRoutingDemux()
Constructor.
IPv6 Extension Destination.
Ipv6ExtensionFragment()
Constructor.
IPv6 Extension Routing.
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.
virtual uint8_t GetExtensionNumber() const
Get the extension number.
std::list< Ptr< Ipv6ExtensionRouting > > Ipv6ExtensionRoutingList_t
Container for the extension routing.
Ptr< Packet > m_unfragmentable
The unfragmentable part.
IPv6 Extension ESP (Encapsulating Security Payload)
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.
virtual uint8_t GetTypeRouting() const
Get the type of routing.
Ipv6ExtensionDestination()
Constructor.
IPv6 Extension Routing Demux.
void SetUnfragmentablePart(Ptr< Packet > unfragmentablePart)
Set the unfragmentable part of the packet.
IPv6 Extension "Hop By Hop".
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.
virtual uint8_t GetExtensionNumber() const
Get the extension number.
void SetNode(Ptr< Node > node)
Set the node.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static TypeId GetTypeId()
Get the type identificator.
virtual uint8_t GetExtensionNumber() const
Get the extension number.
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.
std::pair< Ptr< Packet >, Ipv6Header > Ipv6PayloadHeaderPair
Pair of a packet and an Ipv6 header.
static TypeId GetTypeId()
Get the type identificator.
IPv6 Extension Loose Routing.
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.
IPv6 Extension Fragment.
EventId m_timeoutEventId
Timeout handler event.
Describes an IPv6 address.
Definition: ipv6-address.h:49
An identifier for simulation events.
Definition: event-id.h:53
virtual uint8_t GetExtensionNumber() const
Get the extension number.
Ipv6ExtensionRouting()
Constructor.
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.
bool IsEntire() const
If all fragments have been added.
static const uint8_t EXT_NUMBER
ESP extension number.
virtual uint8_t GetTypeRouting() const
Get the type of routing.
Ptr< Node > GetNode() const
Get the node.
Ipv6ExtensionRoutingList_t m_extensionsRouting
List of IPv6 Routing Extensions supported.
std::list< std::pair< Ptr< Packet >, uint16_t > > m_packetFragments
The current fragments.
virtual uint8_t GetExtensionNumber() const
Get the extension number.
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:87
Ptr< Packet > GetPartialPacket() const
Get the packet parts so far received.
static const uint8_t EXT_NUMBER
Destination extension number.
Ptr< Node > m_node
The node.
virtual uint8_t GetExtensionNumber() const
Get the extension number.
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:58
Ptr< Packet > GetPacket() const
Get the entire packet.
static TypeId GetTypeId()
Get the type identificator.
static const uint8_t EXT_NUMBER
AH extension number.
~Ipv6ExtensionAH()
Destructor.
DropReason
Reason why a packet has been dropped.
virtual ~Ipv6Extension()
Destructor.
IPv6 Extension AH (Authentication Header)