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 
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 
291  typedef std::pair<Ptr<Packet>, Ipv6Header> Ipv6PayloadHeaderPair;
292 
299  void GetFragments (Ptr<Packet> packet, Ipv6Header ipv6Header, uint32_t fragmentSize, std::list<Ipv6PayloadHeaderPair>& listFragments);
300 
301 protected:
305  virtual void DoDispose ();
306 
307 private:
312  class Fragments : public SimpleRefCount<Fragments>
313  {
314 public:
318  Fragments ();
319 
323  ~Fragments ();
324 
331  void AddFragment (Ptr<Packet> fragment, uint16_t fragmentOffset, bool moreFragment);
332 
337  void SetUnfragmentablePart (Ptr<Packet> unfragmentablePart);
338 
343  bool IsEntire () const;
344 
349  Ptr<Packet> GetPacket () const;
350 
355  Ptr<Packet> GetPartialPacket () const;
356 
360  void SetTimeoutEventId (EventId event);
361 
365  void CancelTimeout ();
366 
367 private:
372 
376  std::list<std::pair<Ptr<Packet>, uint16_t> > m_packetFragments;
377 
382 
387  };
388 
394  void HandleFragmentsTimeout (std::pair<Ipv6Address, uint32_t> key, Ipv6Header ipHeader);
395 
400  Ptr<Packet> GetPartialPacket () const;
401 
405  void SetTimeoutEventId (EventId event);
406 
410  void CancelTimeout ();
411 
415  typedef std::map<std::pair<Ipv6Address, uint32_t>, Ptr<Fragments> > MapFragments_t;
416 
420  MapFragments_t m_fragments;
421 };
422 
430 {
431 public:
435  static const uint8_t EXT_NUMBER = 43;
436 
441  static TypeId GetTypeId ();
442 
447 
452 
457  virtual uint8_t GetExtensionNumber () const;
458 
463  virtual uint8_t GetTypeRouting () const;
464 
465  virtual uint8_t Process (Ptr<Packet>& packet,
466  uint8_t offset,
467  Ipv6Header const& ipv6Header,
468  Ipv6Address dst,
469  uint8_t *nextHeader,
470  bool& stopProcessing,
471  bool& isDropped,
472  Ipv6L3Protocol::DropReason& dropReason);
473 };
474 
480 {
481 public:
486  static TypeId GetTypeId ();
487 
492 
496  virtual ~Ipv6ExtensionRoutingDemux ();
497 
502  void SetNode (Ptr<Node> node);
503 
508  void Insert (Ptr<Ipv6ExtensionRouting> extensionRouting);
509 
515  Ptr<Ipv6ExtensionRouting> GetExtensionRouting (uint8_t typeRouting);
516 
521  void Remove (Ptr<Ipv6ExtensionRouting> extensionRouting);
522 
523 protected:
527  virtual void DoDispose ();
528 
529 private:
533  typedef std::list<Ptr<Ipv6ExtensionRouting> > Ipv6ExtensionRoutingList_t;
534 
538  Ipv6ExtensionRoutingList_t m_extensionsRouting;
539 
544 };
545 
551 {
552 public:
556  static const uint8_t TYPE_ROUTING = 0;
557 
562  static TypeId GetTypeId ();
563 
568 
573 
578  virtual uint8_t GetTypeRouting () const;
579 
580  virtual uint8_t Process (Ptr<Packet>& packet,
581  uint8_t offset,
582  Ipv6Header const& ipv6Header,
583  Ipv6Address dst,
584  uint8_t *nextHeader,
585  bool& stopProcessing,
586  bool& isDropped,
587  Ipv6L3Protocol::DropReason& dropReason);
588 };
589 
595 {
596 public:
600  static const uint8_t EXT_NUMBER = 50;
601 
606  static TypeId GetTypeId ();
607 
611  Ipv6ExtensionESP ();
612 
617 
622  virtual uint8_t GetExtensionNumber () const;
623 
624  virtual uint8_t Process (Ptr<Packet>& packet,
625  uint8_t offset,
626  Ipv6Header const& ipv6Header,
627  Ipv6Address dst,
628  uint8_t *nextHeader,
629  bool& stopProcessing,
630  bool& isDropped,
631  Ipv6L3Protocol::DropReason& dropReason);
632 };
633 
639 {
640 public:
644  static const uint8_t EXT_NUMBER = 51;
645 
650  static TypeId GetTypeId ();
651 
655  Ipv6ExtensionAH ();
656 
660  ~Ipv6ExtensionAH ();
661 
666  virtual uint8_t GetExtensionNumber () const;
667 
668  virtual uint8_t Process (Ptr<Packet>& packet,
669  uint8_t offset,
670  Ipv6Header const& ipv6Header,
671  Ipv6Address dst,
672  uint8_t *nextHeader,
673  bool& stopProcessing,
674  bool& isDropped,
675  Ipv6L3Protocol::DropReason& dropReason);
676 };
677 
678 } /* namespace ns3 */
679 
680 #endif /* IPV6_EXTENSION_H */
681 
Ptr< UniformRandomVariable > m_uvar
Provides uniform random variables.
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.
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.
void GetFragments(Ptr< Packet > packet, Ipv6Header ipv6Header, uint32_t fragmentSize, std::list< Ipv6PayloadHeaderPair > &listFragments)
Fragment a packet.
virtual ~Ipv6ExtensionRoutingDemux()
Destructor.
Ipv6ExtensionRoutingDemux()
Constructor.
Introspection did not find any typical Config paths.
Ipv6ExtensionFragment()
Constructor.
virtual uint8_t GetExtensionNumber() const
Get the extension number.
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.
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.
Introspection did not find any typical Config paths.
void SetUnfragmentablePart(Ptr< Packet > unfragmentablePart)
Set the unfragmentable part of the packet.
bool IsEntire() const
If all fragments have been added.
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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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.
std::pair< Ptr< Packet >, Ipv6Header > Ipv6PayloadHeaderPair
Pair of a packet and an Ipv6 header.
static TypeId GetTypeId()
Get the type identificator.
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.
Introspection did not find any typical Config paths.
EventId m_timeoutEventId
Timeout handler event.
Describes an IPv6 address.
Definition: ipv6-address.h:48
virtual uint8_t GetTypeRouting() const
Get the type of routing.
An identifier for simulation events.
Definition: event-id.h:53
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:87
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:58
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.
Introspection did not find any typical Config paths.