SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

La actualidad más candente

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
 

La actualidad más candente (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
 

Destacado (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
 

Similar a 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
 

Similar a 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
 

Último

MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
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
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
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
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
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
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 

Último (20)

MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
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 ...
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
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🔝
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
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
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
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
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........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

Notas del editor

  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