SlideShare une entreprise Scribd logo
1  sur  21
Basic packet
forwarding in
     NS2
   N S 2   U l t i m a t e . c o m
                b y
T e e r a w a t I s s a r i y a k u l
OUTLINE
Before you begin...

NsObject

Packet forwarding

Example

    Class Connector

    Class Queue

Questions?
                       www.ns2ultimate.com
Before you Begin ...


              In NS2:

  • NO such thing as transmission
  • RECEIVE ONLY



                                    www.ns2ultimate.com
What we are going to
      do here
Suppose you’d like to send a packet from one
NsObject to another

What’s NsObject? ➠ See [ this link ]

                   packet
NsObject                          NsObject




                                       www.ns2ultimate.com
NSObjects
Inherited Functionalities:

    Class TclObject ➠ OTcl interface

    Class Handler ➠ Default actions

New Functionalities:

    Receive packet ➠ function recv(p,h)



                                 www.ns2ultimate.com
This section gives an overview of C++ class hierarchies. The entire hierarchy

     NSObjects: Inherited
consists of over 100 C++ classes and struct data types. Here, we only show
a part of the hierarchy (in Fig. 5.1). The readers are referred to [18] for the

       functionalities
complete class hierarchy.


                  OTcl Interface                                     Default Action


                                  TclObject                Handler



     Simulator                PacketQueue      NsObject      AtHandler       QueueHandler

           RoutingModule
                                                      Network Component


                 Classifier                    Connector                    LanRouter


                          Uni-directional Point-to-
                          point Object Connector


                  Queue           Agent       ErrorModel       LinkDelay          Trace

                                                              www.ns2ultimate.com
Fig. 5.1. A part of NS2 C++ class hierarchy (this chapter emphasizes on classes
NSObject: New
     functionality
class NsObject : public TclObject, public Handler {

public:

   NsObject();

   virtual void recv(Packet*, Handler*) = 0;
};




                                        www.ns2ultimate.com
NSObject: New
     functionality
class NsObject : public TclObject, public Handler {

public:

   NsObject();

   virtual void recv(Packet*, Handler*) = 0;
};



          TclObject
                            NsObject
         Handler

                                        www.ns2ultimate.com
NSObject: New
     functionality
class NsObject : public TclObject, public Handler {

public:

   NsObject();

   virtual void recv(Packet*, Handler*) = 0;
};



packet reception function
Input = a pointer to a Packet object
Input = a pointer to a Handler object
abstract function
                                        www.ns2ultimate.com
packet forwarding
NS2 refers to most objects using pointers

Including NsObjects and Packets

Example

   “p” = a pointer

    “*p” = a place where the pointer “p” pointer
   to


                                      www.ns2ultimate.com
packet forwarding
Task: An object “*s” sends packet “*p” to an
object “*d”


 s                      p                  d

                   packet
NsObject                           NsObject



                                      www.ns2ultimate.com
C++ Statement
From within “*s”, execute one of the following
two C++ Statements:

     Given a handler *h: “d->recv(p,h)”
     Handler does not exists: “d->recv(p)”
 s                      p                  d

                   packet
NsObject                           NsObject
                                      www.ns2ultimate.com
Chapter 15.



                      Examples
5.1.2 C++ Class Hierarchy

This section gives an overview of C++ class hierarchies. The entire hierarchy
consists of over 100 C++ classes and struct data types. Here, we only show
a part of the hierarchy (in Fig. 5.1). The readers are referred to [18] for the
Six main categories
complete class hierarchy.


                  OTcl Interface                                     Default Action


                                  TclObject                Handler



     Simulator                PacketQueue      NsObject      AtHandler       QueueHandler

           RoutingModule
                                                      Network Component


                 Classifier                    Connector                    LanRouter


                          Uni-directional Point-to-
                          point Object Connector


                  Queue           Agent       ErrorModel       LinkDelay          Trace

Fig. 5.1. A part of NS2 C++ class hierarchy (this chapter emphasizes on classes
in boxes with thick solid lines).                              www.ns2ultimate.com
Example:
     Class Connector
class Connector : public NsObject {

public:


    Connector();


    NsObject* target_;

     NsObject* drop_;

};                        • Class variable
                          • A pointer to NsObject
                                     www.ns2ultimate.com
Class Connector
Example configuration
 target_ points to the next NsObject
 drop_ points to an NsObject responsible for
 dropping a packet
   100 5 Network Objects

                               Connector

      NsObject                                                        NsObject
                                 target_
         Upstream                           Packet forwarding path      Downstream
         NsObject                                                        NsObject
                                 drop_


                      Packet
                    dropping
                        path

                        NsObject
                          Packet Dropping
                             NsObject                                www.ns2ultimate.com
Class Connector
To drop a packet, “send the packet to the
dropping NsObject”

      void Connector::drop(Packet* p)
      {
      
 if (drop_ != 0)
      
 
 drop_->recv(p);
      
 else
      
 
 Packet::free(p);
      }

                      Send a packet *p to the
                      NsObject *drop_
                                        www.ns2ultimate.com
5.1.2 C++ Class Hierarchy

          Another example:
This section gives an overview of C++ class hierarchies. The entire hierarchy
consists of over 100 C++ classes and struct data types. Here, we only show

            Class Queue
a part of the hierarchy (in Fig. 5.1). The readers are referred to [18] for the
complete class hierarchy.


                  OTcl Interface                                     Default Action


                                  TclObject                Handler



     Simulator                PacketQueue      NsObject      AtHandler       QueueHandler

           RoutingModule
                                                      Network Component


                 Classifier                    Connector                    LanRouter


                          Uni-directional Point-to-
                          point Object Connector
                                                      Derive from class Connector

                  Queue           Agent       ErrorModel       LinkDelay          Trace

Fig. 5.1. A part of NS2 C++ class hierarchy (this chapter emphasizes on classes
                 Contain pointers target_ and drop_.
in boxes with thick solid lines).

                                                                                          www.ns2ultimate.com
Another example:
   Class Queue
void Queue::recv(Packet* p, Handler*)
{

 double now = Scheduler::instance().clock();

 enque(p);

 if (!blocked_) {

 
 p = deque();

 
 if (p != 0) {

 
 
 blocked_ = 1;

 
 
 target_->recv(p, &qh_);

 
 }

 }
}

     Send a packet *p to the NsObject
     *target_ with a handler qh_ www.ns2ultimate.com
Questions?
How doNetwork Objectsa topology like this?
 100 5 we setup

                                   Connector

         NsObject                                                        NsObject
                                     target_
            Upstream                            Packet forwarding path     Downstream
            NsObject                                                        NsObject
                                     drop_


                          Packet
                        dropping
                            path

                            NsObject
                              Packet Dropping
                                 NsObject

 Fig. 5.2. Diagram of a connector: The solid arrows represent pointers, while the
What about handler? What is it? What are its
 dotted arrows show packet forwarding and dropping paths.

implications?
 Program 5.3 Declaration and function recv(p,h) of class Connector
         //~/ns/common/connector.h
     1   class Connector : public NsObject {                              www.ns2ultimate.com
Stay Tune!
I’ll discuss these
 in the following
       posts!
For more
 information
  about NS2

   P l e a s        e   s e e
    t h i s         b o o k
         f r        o m
     S p r i        n g e r
T. Issaraiyakul and E. Hossain, “Introduction to Network Simulator NS2”, Springer 2009

 or visit www.ns2ultimate.com

Contenu connexe

Tendances

Concurrency in Programming Languages
Concurrency in Programming LanguagesConcurrency in Programming Languages
Concurrency in Programming LanguagesYudong Li
 
Arduino C maXbox web of things slide show
Arduino C maXbox web of things slide showArduino C maXbox web of things slide show
Arduino C maXbox web of things slide showMax Kleiner
 
iOS Development with Blocks
iOS Development with BlocksiOS Development with Blocks
iOS Development with BlocksJeff Kelley
 
ConFess Vienna 2015 - Metaprogramming with Groovy
ConFess Vienna 2015 - Metaprogramming with GroovyConFess Vienna 2015 - Metaprogramming with Groovy
ConFess Vienna 2015 - Metaprogramming with GroovyIván López Martín
 
Lec 42.43 - virtual.functions
Lec 42.43 - virtual.functionsLec 42.43 - virtual.functions
Lec 42.43 - virtual.functionsPrincess Sam
 
Start Wrap Episode 11: A New Rope
Start Wrap Episode 11: A New RopeStart Wrap Episode 11: A New Rope
Start Wrap Episode 11: A New RopeYung-Yu Chen
 
AST Transformations at JFokus
AST Transformations at JFokusAST Transformations at JFokus
AST Transformations at JFokusHamletDRC
 
Operator overloading2
Operator overloading2Operator overloading2
Operator overloading2zindadili
 
Building High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low EffortBuilding High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low EffortStefan Marr
 
Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...
Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...
Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...Stefan Marr
 
Virtual function
Virtual functionVirtual function
Virtual functionharman kaur
 
Python and GObject Introspection
Python and GObject IntrospectionPython and GObject Introspection
Python and GObject IntrospectionYuren Ju
 
Rust Workshop - NITC FOSSMEET 2017
Rust Workshop - NITC FOSSMEET 2017 Rust Workshop - NITC FOSSMEET 2017
Rust Workshop - NITC FOSSMEET 2017 pramode_ce
 
What's New In C# 5.0 - Rumos InsideOut
What's New In C# 5.0 - Rumos InsideOutWhat's New In C# 5.0 - Rumos InsideOut
What's New In C# 5.0 - Rumos InsideOutPaulo Morgado
 

Tendances (20)

Concurrency in Programming Languages
Concurrency in Programming LanguagesConcurrency in Programming Languages
Concurrency in Programming Languages
 
Arduino C maXbox web of things slide show
Arduino C maXbox web of things slide showArduino C maXbox web of things slide show
Arduino C maXbox web of things slide show
 
iOS Development with Blocks
iOS Development with BlocksiOS Development with Blocks
iOS Development with Blocks
 
Thread
ThreadThread
Thread
 
ConFess Vienna 2015 - Metaprogramming with Groovy
ConFess Vienna 2015 - Metaprogramming with GroovyConFess Vienna 2015 - Metaprogramming with Groovy
ConFess Vienna 2015 - Metaprogramming with Groovy
 
Lec 42.43 - virtual.functions
Lec 42.43 - virtual.functionsLec 42.43 - virtual.functions
Lec 42.43 - virtual.functions
 
Extending Node.js using C++
Extending Node.js using C++Extending Node.js using C++
Extending Node.js using C++
 
Start Wrap Episode 11: A New Rope
Start Wrap Episode 11: A New RopeStart Wrap Episode 11: A New Rope
Start Wrap Episode 11: A New Rope
 
Bab3of
Bab3ofBab3of
Bab3of
 
Node.js extensions in C++
Node.js extensions in C++Node.js extensions in C++
Node.js extensions in C++
 
AST Transformations at JFokus
AST Transformations at JFokusAST Transformations at JFokus
AST Transformations at JFokus
 
Operator overloading2
Operator overloading2Operator overloading2
Operator overloading2
 
Building High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low EffortBuilding High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low Effort
 
Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...
Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...
Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...
 
Virtual function
Virtual functionVirtual function
Virtual function
 
Python and GObject Introspection
Python and GObject IntrospectionPython and GObject Introspection
Python and GObject Introspection
 
강의자료8
강의자료8강의자료8
강의자료8
 
Rust Workshop - NITC FOSSMEET 2017
Rust Workshop - NITC FOSSMEET 2017 Rust Workshop - NITC FOSSMEET 2017
Rust Workshop - NITC FOSSMEET 2017
 
What's New In C# 5.0 - Rumos InsideOut
What's New In C# 5.0 - Rumos InsideOutWhat's New In C# 5.0 - Rumos InsideOut
What's New In C# 5.0 - Rumos InsideOut
 
Java Concurrency
Java ConcurrencyJava Concurrency
Java Concurrency
 

En vedette (18)

Dynamic UID
Dynamic UIDDynamic UID
Dynamic UID
 
NS2: Events and Handlers
NS2: Events and HandlersNS2: Events and Handlers
NS2: Events and Handlers
 
NS2--Event Scheduler
NS2--Event SchedulerNS2--Event Scheduler
NS2--Event Scheduler
 
Trump-Style Negotiation: Powerful Strategies and Tactics for Mastering Every ...
Trump-Style Negotiation: Powerful Strategies and Tactics for Mastering Every ...Trump-Style Negotiation: Powerful Strategies and Tactics for Mastering Every ...
Trump-Style Negotiation: Powerful Strategies and Tactics for Mastering Every ...
 
NS-2 Tutorial
NS-2 TutorialNS-2 Tutorial
NS-2 Tutorial
 
Ns2
Ns2Ns2
Ns2
 
Introduction to statistics ii
Introduction to statistics iiIntroduction to statistics ii
Introduction to statistics ii
 
Introduction of suffix tree
Introduction of suffix treeIntroduction of suffix tree
Introduction of suffix tree
 
Packet forwarding in wan.46
Packet  forwarding in wan.46Packet  forwarding in wan.46
Packet forwarding in wan.46
 
Trie tree
Trie treeTrie tree
Trie tree
 
Intelligent entrepreneurs by Bill Murphy Jr.
Intelligent entrepreneurs by Bill Murphy Jr.Intelligent entrepreneurs by Bill Murphy Jr.
Intelligent entrepreneurs by Bill Murphy Jr.
 
Suffix Tree and Suffix Array
Suffix Tree and Suffix ArraySuffix Tree and Suffix Array
Suffix Tree and Suffix Array
 
Data structure tries
Data structure triesData structure tries
Data structure tries
 
Ns-2.35 Installation
Ns-2.35 InstallationNs-2.35 Installation
Ns-2.35 Installation
 
Lec18
Lec18Lec18
Lec18
 
20111107 ns2-required cygwinpkg
20111107 ns2-required cygwinpkg20111107 ns2-required cygwinpkg
20111107 ns2-required cygwinpkg
 
Network simulator 2
Network simulator 2Network simulator 2
Network simulator 2
 
20111126 ns2 installation
20111126 ns2 installation20111126 ns2 installation
20111126 ns2 installation
 

Similaire à Basic Packet Forwarding in NS2

PATTERNS09 - Generics in .NET and Java
PATTERNS09 - Generics in .NET and JavaPATTERNS09 - Generics in .NET and Java
PATTERNS09 - Generics in .NET and JavaMichael Heron
 
C++aptitude questions and answers
C++aptitude questions and answersC++aptitude questions and answers
C++aptitude questions and answerssheibansari
 
Lecture 5: Functional Programming
Lecture 5: Functional ProgrammingLecture 5: Functional Programming
Lecture 5: Functional ProgrammingEelco Visser
 
Dancing Links: an educational pearl
Dancing Links: an educational pearlDancing Links: an educational pearl
Dancing Links: an educational pearlESUG
 
The Ring programming language version 1.8 book - Part 86 of 202
The Ring programming language version 1.8 book - Part 86 of 202The Ring programming language version 1.8 book - Part 86 of 202
The Ring programming language version 1.8 book - Part 86 of 202Mahmoud Samir Fayed
 
Lecture20 vector
Lecture20 vectorLecture20 vector
Lecture20 vectornurkhaledah
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithmsmultimedia9
 
Compact and safely: static DSL on Kotlin
Compact and safely: static DSL on KotlinCompact and safely: static DSL on Kotlin
Compact and safely: static DSL on KotlinDmitry Pranchuk
 
Funddamentals of data structures
Funddamentals of data structuresFunddamentals of data structures
Funddamentals of data structuresGlobalidiots
 
Functional programming with Scala
Functional programming with ScalaFunctional programming with Scala
Functional programming with ScalaNeelkanth Sachdeva
 
Scala for Java Developers
Scala for Java DevelopersScala for Java Developers
Scala for Java DevelopersMartin Ockajak
 
Efficient Model Partitioning for Distributed Model Transformations
Efficient Model Partitioning for Distributed Model TransformationsEfficient Model Partitioning for Distributed Model Transformations
Efficient Model Partitioning for Distributed Model TransformationsAmine Benelallam
 

Similaire à Basic Packet Forwarding in NS2 (20)

iOS Session-2
iOS Session-2iOS Session-2
iOS Session-2
 
PATTERNS09 - Generics in .NET and Java
PATTERNS09 - Generics in .NET and JavaPATTERNS09 - Generics in .NET and Java
PATTERNS09 - Generics in .NET and Java
 
C++aptitude questions and answers
C++aptitude questions and answersC++aptitude questions and answers
C++aptitude questions and answers
 
Lecture 5: Functional Programming
Lecture 5: Functional ProgrammingLecture 5: Functional Programming
Lecture 5: Functional Programming
 
Ns2
Ns2Ns2
Ns2
 
Dancing Links: an educational pearl
Dancing Links: an educational pearlDancing Links: an educational pearl
Dancing Links: an educational pearl
 
Extending ns
Extending nsExtending ns
Extending ns
 
The Ring programming language version 1.8 book - Part 86 of 202
The Ring programming language version 1.8 book - Part 86 of 202The Ring programming language version 1.8 book - Part 86 of 202
The Ring programming language version 1.8 book - Part 86 of 202
 
Lecture20 vector
Lecture20 vectorLecture20 vector
Lecture20 vector
 
Lec3
Lec3Lec3
Lec3
 
Module IV_updated(old).pdf
Module IV_updated(old).pdfModule IV_updated(old).pdf
Module IV_updated(old).pdf
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
 
Compact and safely: static DSL on Kotlin
Compact and safely: static DSL on KotlinCompact and safely: static DSL on Kotlin
Compact and safely: static DSL on Kotlin
 
C++ aptitude
C++ aptitudeC++ aptitude
C++ aptitude
 
Functional object
Functional objectFunctional object
Functional object
 
Funddamentals of data structures
Funddamentals of data structuresFunddamentals of data structures
Funddamentals of data structures
 
Functional programming with Scala
Functional programming with ScalaFunctional programming with Scala
Functional programming with Scala
 
CPP homework help
CPP homework helpCPP homework help
CPP homework help
 
Scala for Java Developers
Scala for Java DevelopersScala for Java Developers
Scala for Java Developers
 
Efficient Model Partitioning for Distributed Model Transformations
Efficient Model Partitioning for Distributed Model TransformationsEfficient Model Partitioning for Distributed Model Transformations
Efficient Model Partitioning for Distributed Model Transformations
 

Dernier

BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 

Dernier (20)

BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 

Basic Packet Forwarding in NS2

  • 1. Basic packet forwarding in NS2 N S 2 U l t i m a t e . c o m b y T e e r a w a t I s s a r i y a k u l
  • 2. OUTLINE Before you begin... NsObject Packet forwarding Example Class Connector Class Queue Questions? www.ns2ultimate.com
  • 3. Before you Begin ... In NS2: • NO such thing as transmission • RECEIVE ONLY www.ns2ultimate.com
  • 4. What we are going to do here Suppose you’d like to send a packet from one NsObject to another What’s NsObject? ➠ See [ this link ] packet NsObject NsObject www.ns2ultimate.com
  • 5. NSObjects Inherited Functionalities: Class TclObject ➠ OTcl interface Class Handler ➠ Default actions New Functionalities: Receive packet ➠ function recv(p,h) www.ns2ultimate.com
  • 6. This section gives an overview of C++ class hierarchies. The entire hierarchy NSObjects: Inherited consists of over 100 C++ classes and struct data types. Here, we only show a part of the hierarchy (in Fig. 5.1). The readers are referred to [18] for the functionalities complete class hierarchy. OTcl Interface Default Action TclObject Handler Simulator PacketQueue NsObject AtHandler QueueHandler RoutingModule Network Component Classifier Connector LanRouter Uni-directional Point-to- point Object Connector Queue Agent ErrorModel LinkDelay Trace www.ns2ultimate.com Fig. 5.1. A part of NS2 C++ class hierarchy (this chapter emphasizes on classes
  • 7. NSObject: New functionality class NsObject : public TclObject, public Handler { public: NsObject(); virtual void recv(Packet*, Handler*) = 0; }; www.ns2ultimate.com
  • 8. NSObject: New functionality class NsObject : public TclObject, public Handler { public: NsObject(); virtual void recv(Packet*, Handler*) = 0; }; TclObject NsObject Handler www.ns2ultimate.com
  • 9. NSObject: New functionality class NsObject : public TclObject, public Handler { public: NsObject(); virtual void recv(Packet*, Handler*) = 0; }; packet reception function Input = a pointer to a Packet object Input = a pointer to a Handler object abstract function www.ns2ultimate.com
  • 10. packet forwarding NS2 refers to most objects using pointers Including NsObjects and Packets Example “p” = a pointer “*p” = a place where the pointer “p” pointer to www.ns2ultimate.com
  • 11. packet forwarding Task: An object “*s” sends packet “*p” to an object “*d” s p d packet NsObject NsObject www.ns2ultimate.com
  • 12. C++ Statement From within “*s”, execute one of the following two C++ Statements: Given a handler *h: “d->recv(p,h)” Handler does not exists: “d->recv(p)” s p d packet NsObject NsObject www.ns2ultimate.com
  • 13. Chapter 15. Examples 5.1.2 C++ Class Hierarchy This section gives an overview of C++ class hierarchies. The entire hierarchy consists of over 100 C++ classes and struct data types. Here, we only show a part of the hierarchy (in Fig. 5.1). The readers are referred to [18] for the Six main categories complete class hierarchy. OTcl Interface Default Action TclObject Handler Simulator PacketQueue NsObject AtHandler QueueHandler RoutingModule Network Component Classifier Connector LanRouter Uni-directional Point-to- point Object Connector Queue Agent ErrorModel LinkDelay Trace Fig. 5.1. A part of NS2 C++ class hierarchy (this chapter emphasizes on classes in boxes with thick solid lines). www.ns2ultimate.com
  • 14. Example: Class Connector class Connector : public NsObject { public: Connector(); NsObject* target_; NsObject* drop_; }; • Class variable • A pointer to NsObject www.ns2ultimate.com
  • 15. Class Connector Example configuration target_ points to the next NsObject drop_ points to an NsObject responsible for dropping a packet 100 5 Network Objects Connector NsObject NsObject target_ Upstream Packet forwarding path Downstream NsObject NsObject drop_ Packet dropping path NsObject Packet Dropping NsObject www.ns2ultimate.com
  • 16. Class Connector To drop a packet, “send the packet to the dropping NsObject” void Connector::drop(Packet* p) { if (drop_ != 0) drop_->recv(p); else Packet::free(p); } Send a packet *p to the NsObject *drop_ www.ns2ultimate.com
  • 17. 5.1.2 C++ Class Hierarchy Another example: This section gives an overview of C++ class hierarchies. The entire hierarchy consists of over 100 C++ classes and struct data types. Here, we only show Class Queue a part of the hierarchy (in Fig. 5.1). The readers are referred to [18] for the complete class hierarchy. OTcl Interface Default Action TclObject Handler Simulator PacketQueue NsObject AtHandler QueueHandler RoutingModule Network Component Classifier Connector LanRouter Uni-directional Point-to- point Object Connector Derive from class Connector Queue Agent ErrorModel LinkDelay Trace Fig. 5.1. A part of NS2 C++ class hierarchy (this chapter emphasizes on classes Contain pointers target_ and drop_. in boxes with thick solid lines). www.ns2ultimate.com
  • 18. Another example: Class Queue void Queue::recv(Packet* p, Handler*) { double now = Scheduler::instance().clock(); enque(p); if (!blocked_) { p = deque(); if (p != 0) { blocked_ = 1; target_->recv(p, &qh_); } } } Send a packet *p to the NsObject *target_ with a handler qh_ www.ns2ultimate.com
  • 19. Questions? How doNetwork Objectsa topology like this? 100 5 we setup Connector NsObject NsObject target_ Upstream Packet forwarding path Downstream NsObject NsObject drop_ Packet dropping path NsObject Packet Dropping NsObject Fig. 5.2. Diagram of a connector: The solid arrows represent pointers, while the What about handler? What is it? What are its dotted arrows show packet forwarding and dropping paths. implications? Program 5.3 Declaration and function recv(p,h) of class Connector //~/ns/common/connector.h 1 class Connector : public NsObject { www.ns2ultimate.com
  • 20. Stay Tune! I’ll discuss these in the following posts!
  • 21. For more information about NS2 P l e a s e s e e t h i s b o o k f r o m S p r i n g e r T. Issaraiyakul and E. Hossain, “Introduction to Network Simulator NS2”, Springer 2009 or visit www.ns2ultimate.com

Notes de l'éditeur

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n