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#include <tuple>
27
28#include "ns3/object.h"
29#include "ns3/node.h"
30#include "ns3/ptr.h"
31#include "ipv6-interface.h"
32#include "ns3/ipv6-header.h"
33#include "ns3/buffer.h"
34#include "ns3/packet.h"
35#include "ns3/random-variable-stream.h"
36#include "ns3/ipv6-address.h"
37#include "ns3/ipv6-l3-protocol.h"
38#include "ns3/traced-callback.h"
39
40
41namespace ns3 {
42
55class Ipv6Extension : public Object
56{
57public:
62 static TypeId GetTypeId ();
63
68
72 virtual ~Ipv6Extension ();
73
78 void SetNode (Ptr<Node> node);
79
84 Ptr<Node> GetNode () const;
85
90 virtual uint8_t GetExtensionNumber () const = 0;
91
106 virtual uint8_t Process (Ptr<Packet>& packet,
107 uint8_t offset,
108 Ipv6Header const& ipv6Header,
109 Ipv6Address dst,
110 uint8_t *nextHeader,
111 bool& stopProcessing,
112 bool& isDropped,
113 Ipv6L3Protocol::DropReason& dropReason) = 0;
114
130 virtual uint8_t ProcessOptions (Ptr<Packet>& packet,
131 uint8_t offset,
132 uint8_t length,
133 Ipv6Header const& ipv6Header,
134 Ipv6Address dst,
135 uint8_t *nextHeader,
136 bool& stopProcessing,
137 bool& isDropped,
139 );
140
149 int64_t AssignStreams (int64_t stream);
150
151protected:
156
157private:
162};
163
170{
171public:
175 static const uint8_t EXT_NUMBER = 0;
176
181 static TypeId GetTypeId ();
182
187
192
197 virtual uint8_t GetExtensionNumber () const;
198
199 virtual uint8_t Process (Ptr<Packet>& packet,
200 uint8_t offset,
201 Ipv6Header const& ipv6Header,
202 Ipv6Address dst,
203 uint8_t *nextHeader,
204 bool& stopProcessing,
205 bool& isDropped,
206 Ipv6L3Protocol::DropReason& dropReason);
207};
208
215{
216public:
220 static const uint8_t EXT_NUMBER = 60;
221
226 static TypeId GetTypeId ();
227
232
237
242 virtual uint8_t GetExtensionNumber () const;
243
244 virtual uint8_t Process (Ptr<Packet>& packet,
245 uint8_t offset,
246 Ipv6Header const& ipv6Header,
247 Ipv6Address dst,
248 uint8_t *nextHeader,
249 bool& stopProcessing,
250 bool& isDropped,
251 Ipv6L3Protocol::DropReason& dropReason);
252};
253
260{
261public:
265 static const uint8_t EXT_NUMBER = 44;
266
271 static TypeId GetTypeId ();
272
277
282
287 virtual uint8_t GetExtensionNumber () const;
288
289 virtual uint8_t Process (Ptr<Packet>& packet,
290 uint8_t offset,
291 Ipv6Header const& ipv6Header,
292 Ipv6Address dst,
293 uint8_t *nextHeader,
294 bool& stopProcessing,
295 bool& isDropped,
296 Ipv6L3Protocol::DropReason& dropReason);
297
301 typedef std::pair<Ptr<Packet>, Ipv6Header> Ipv6PayloadHeaderPair;
302
311 void GetFragments (Ptr<Packet> packet, Ipv6Header ipv6Header, uint32_t fragmentSize, std::list<Ipv6PayloadHeaderPair>& listFragments);
312
313protected:
317 virtual void DoDispose ();
318
319private:
320
324 typedef std::pair<Ipv6Address, uint32_t> FragmentKey_t;
325
329 typedef std::list< std::tuple <Time, FragmentKey_t, Ipv6Header > > FragmentsTimeoutsList_t;
333 typedef std::list< std::tuple <Time, FragmentKey_t, Ipv6Header > >::iterator FragmentsTimeoutsListI_t;
334
340 class Fragments : public SimpleRefCount<Fragments>
341 {
342public:
346 Fragments ();
347
351 ~Fragments ();
352
359 void AddFragment (Ptr<Packet> fragment, uint16_t fragmentOffset, bool moreFragment);
360
365 void SetUnfragmentablePart (Ptr<Packet> unfragmentablePart);
366
371 bool IsEntire () const;
372
377 Ptr<Packet> GetPacket () const;
378
384
390
396
397private:
402
406 std::list<std::pair<Ptr<Packet>, uint16_t> > m_packetFragments;
407
412
417 };
418
425
431
437
442
446 typedef std::map<FragmentKey_t, Ptr<Fragments> > MapFragments_t;
447
452
460
464 void HandleTimeout (void);
465
469};
470
480{
481public:
485 static const uint8_t EXT_NUMBER = 43;
486
491 static TypeId GetTypeId ();
492
497
502
507 virtual uint8_t GetExtensionNumber () const;
508
513 virtual uint8_t GetTypeRouting () const;
514
515 virtual uint8_t Process (Ptr<Packet>& packet,
516 uint8_t offset,
517 Ipv6Header const& ipv6Header,
518 Ipv6Address dst,
519 uint8_t *nextHeader,
520 bool& stopProcessing,
521 bool& isDropped,
522 Ipv6L3Protocol::DropReason& dropReason);
523};
524
531{
532public:
537 static TypeId GetTypeId ();
538
543
548
553 void SetNode (Ptr<Node> node);
554
559 void Insert (Ptr<Ipv6ExtensionRouting> extensionRouting);
560
567
572 void Remove (Ptr<Ipv6ExtensionRouting> extensionRouting);
573
574protected:
578 virtual void DoDispose ();
579
580private:
584 typedef std::list<Ptr<Ipv6ExtensionRouting> > Ipv6ExtensionRoutingList_t;
585
590
595};
596
603{
604public:
608 static const uint8_t TYPE_ROUTING = 0;
609
614 static TypeId GetTypeId ();
615
620
625
630 virtual uint8_t GetTypeRouting () const;
631
632 virtual uint8_t Process (Ptr<Packet>& packet,
633 uint8_t offset,
634 Ipv6Header const& ipv6Header,
635 Ipv6Address dst,
636 uint8_t *nextHeader,
637 bool& stopProcessing,
638 bool& isDropped,
639 Ipv6L3Protocol::DropReason& dropReason);
640};
641
648{
649public:
653 static const uint8_t EXT_NUMBER = 50;
654
659 static TypeId GetTypeId ();
660
665
670
675 virtual uint8_t GetExtensionNumber () const;
676
677 virtual uint8_t Process (Ptr<Packet>& packet,
678 uint8_t offset,
679 Ipv6Header const& ipv6Header,
680 Ipv6Address dst,
681 uint8_t *nextHeader,
682 bool& stopProcessing,
683 bool& isDropped,
684 Ipv6L3Protocol::DropReason& dropReason);
685};
686
693{
694public:
698 static const uint8_t EXT_NUMBER = 51;
699
704 static TypeId GetTypeId ();
705
710
715
720 virtual uint8_t GetExtensionNumber () const;
721
722 virtual uint8_t Process (Ptr<Packet>& packet,
723 uint8_t offset,
724 Ipv6Header const& ipv6Header,
725 Ipv6Address dst,
726 uint8_t *nextHeader,
727 bool& stopProcessing,
728 bool& isDropped,
729 Ipv6L3Protocol::DropReason& dropReason);
730};
731
732} /* namespace ns3 */
733
734#endif /* IPV6_EXTENSION_H */
735
An identifier for simulation events.
Definition: event-id.h:54
Describes an IPv6 address.
Definition: ipv6-address.h:50
IPv6 Extension AH (Authentication Header)
virtual uint8_t GetExtensionNumber() const
Get the extension number.
static TypeId GetTypeId()
Get the type identificator.
~Ipv6ExtensionAH()
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.
Ipv6ExtensionAH()
Constructor.
static const uint8_t EXT_NUMBER
AH extension number.
IPv6 Extension Destination.
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 const uint8_t EXT_NUMBER
Destination extension number.
static TypeId GetTypeId()
Get the type identificator.
virtual uint8_t GetExtensionNumber() const
Get the extension number.
IPv6 Extension ESP (Encapsulating Security Payload)
Ipv6ExtensionESP()
Constructor.
virtual uint8_t GetExtensionNumber() const
Get the extension number.
~Ipv6ExtensionESP()
Destructor.
static const uint8_t EXT_NUMBER
ESP extension number.
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.
This class stores the fragments of a packet waiting to be rebuilt.
Ptr< Packet > GetPartialPacket() const
Get the packet parts so far received.
Ptr< Packet > GetPacket() const
Get the entire packet.
std::list< std::pair< Ptr< Packet >, uint16_t > > m_packetFragments
The current fragments.
void AddFragment(Ptr< Packet > fragment, uint16_t fragmentOffset, bool moreFragment)
Add a fragment.
void SetTimeoutIter(FragmentsTimeoutsListI_t iter)
Set the Timeout iterator.
bool m_moreFragment
If other fragments will be sent.
Ptr< Packet > m_unfragmentable
The unfragmentable part.
FragmentsTimeoutsListI_t m_timeoutIter
Timeout iterator to "event" handler.
void SetUnfragmentablePart(Ptr< Packet > unfragmentablePart)
Set the unfragmentable part of the packet.
bool IsEntire() const
If all fragments have been added.
FragmentsTimeoutsListI_t GetTimeoutIter()
Get the Timeout iterator.
IPv6 Extension Fragment.
virtual uint8_t GetExtensionNumber() const
Get the extension number.
Time m_fragmentExpirationTimeout
Expiration timeout.
Ptr< Packet > GetPartialPacket() const
Get the packet parts so far received.
Ipv6ExtensionFragment()
Constructor.
std::list< std::tuple< Time, FragmentKey_t, Ipv6Header > > FragmentsTimeoutsList_t
Container for fragment timeouts.
static TypeId GetTypeId()
Get the type identificator.
std::pair< Ptr< Packet >, Ipv6Header > Ipv6PayloadHeaderPair
Pair of a packet and an Ipv6 header.
void GetFragments(Ptr< Packet > packet, Ipv6Header ipv6Header, uint32_t fragmentSize, std::list< Ipv6PayloadHeaderPair > &listFragments)
Fragment a packet.
std::pair< Ipv6Address, uint32_t > FragmentKey_t
Key identifying a fragmented packet.
virtual void DoDispose()
Dispose this object.
EventId m_timeoutEvent
Event for the next scheduled timeout.
std::map< FragmentKey_t, Ptr< Fragments > > MapFragments_t
Container for the packet fragments.
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.
MapFragments_t m_fragments
The hash of fragmented packets.
void SetTimeoutEventId(EventId event)
Set the Timeout EventId.
std::list< std::tuple< Time, FragmentKey_t, Ipv6Header > >::iterator FragmentsTimeoutsListI_t
Container Iterator for fragment timeouts.
void HandleTimeout(void)
Handles a fragmented packet timeout.
FragmentsTimeoutsList_t m_timeoutEventList
Timeout "events" container.
void HandleFragmentsTimeout(FragmentKey_t key, Ipv6Header ipHeader)
Process the timeout for packet fragments.
FragmentsTimeoutsListI_t SetTimeout(FragmentKey_t key, Ipv6Header ipHeader)
Set a new timeout "event" for a fragmented packet.
static const uint8_t EXT_NUMBER
Fragmentation extension number.
void CancelTimeout()
Cancel the timeout event.
IPv6 Extension "Hop By Hop".
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 GetExtensionNumber() const
Get the extension number.
Ipv6ExtensionHopByHop()
Constructor.
static const uint8_t EXT_NUMBER
Hop-by-hop extension number.
IPv6 Extension base If you want to implement a new IPv6 extension, all you have to do is implement a ...
Ptr< Node > GetNode() const
Get the node.
virtual uint8_t GetExtensionNumber() const =0
Get the extension number.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Ptr< Node > m_node
The node.
void SetNode(Ptr< Node > node)
Set the node.
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.
Ptr< UniformRandomVariable > m_uvar
Provides uniform random variables.
Ipv6Extension()
Constructor.
virtual ~Ipv6Extension()
Destructor.
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.
static TypeId GetTypeId()
Get the type identificator.
IPv6 Extension Loose Routing.
static TypeId GetTypeId()
Get the type identificator.
virtual uint8_t GetTypeRouting() const
Get the type of routing.
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 const uint8_t TYPE_ROUTING
Routing type.
IPv6 Extension Routing Demux.
virtual void DoDispose()
Dispose this object.
std::list< Ptr< Ipv6ExtensionRouting > > Ipv6ExtensionRoutingList_t
Container for the extension routing.
virtual ~Ipv6ExtensionRoutingDemux()
Destructor.
void Insert(Ptr< Ipv6ExtensionRouting > extensionRouting)
Insert a new IPv6 Routing Extension.
static TypeId GetTypeId()
The interface ID.
void SetNode(Ptr< Node > node)
Set the node.
Ptr< Ipv6ExtensionRouting > GetExtensionRouting(uint8_t typeRouting)
Get the routing extension corresponding to typeRouting.
void Remove(Ptr< Ipv6ExtensionRouting > extensionRouting)
Remove a routing extension from this demux.
Ptr< Node > m_node
The node.
Ipv6ExtensionRoutingList_t m_extensionsRouting
List of IPv6 Routing Extensions supported.
IPv6 Extension Routing.
virtual uint8_t GetExtensionNumber() const
Get the extension number.
static const uint8_t EXT_NUMBER
Routing extension number.
Ipv6ExtensionRouting()
Constructor.
~Ipv6ExtensionRouting()
Destructor.
static TypeId GetTypeId()
Get the type identificator.
virtual uint8_t GetTypeRouting() const
Get the type of routing.
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.
Packet header for IPv6.
Definition: ipv6-header.h:36
DropReason
Reason why a packet has been dropped.
A base class which provides memory management and object aggregation.
Definition: object.h:88
A template-based reference counting class.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.