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

What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 

Dernier (20)

What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 

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