• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
packet destruction in NS2
 

packet destruction in NS2

on

  • 5,067 views

 

Statistics

Views

Total Views
5,067
Views on SlideShare
2,576
Embed Views
2,491

Actions

Likes
2
Downloads
109
Comments
0

6 Embeds 2,491

http://www.ns2ultimate.com 2298
http://ns2ultimate.tumblr.com 166
http://www.tumblr.com 18
http://translate.googleusercontent.com 4
http://translate.googleusercontent.com 4
http://feeds.feedburner.com 1

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

packet destruction in NS2 packet destruction in NS2 Presentation Transcript

  • packetdestruction in NS2 N S 2 U l t i m a t e . c o m b yT e e r a w a t I s s a r i y a k u l August 2011 1
  • OUTLINEReview of main packet operationsPacket destruction function• Direct packet destruction (Packet::free(p))• Send to a dropping objectExample packet dropping process 2 www.ns2ultimate.com
  • review of packet operationsThree main operations1.Packet creation2.Packet transmission3.Packet destruction 3 www.ns2ultimate.com
  • review of packet operations Three main operations Operation Class Function allocpkt(),1. Packet construction Agent initpkt()2. Packet forwarding NsObject recv(p,h)3. Packet destruction Packet free() 4 www.ns2ultimate.com
  • Packet Creation Two key functions are ➠ Agent::allocpkt() ➠ Agent::initpkt() void Agent::initpkt(Packet* p) const { hdr_cmn* ch = hdr_cmn::access(p); ch->ptype() = type_; Agent::allocpkt() const ch->size() = size_; { Packet* p = Packet::alloc(); hdr_ip* iph = hdr_ip::access(p); initpkt(p); iph->saddr() = here_.addr_; return (p); iph->sport() = here_.port_; } iph->daddr() = dst_.addr_; iph->dport() = dst_.port_; ... } 5 www.ns2ultimate.com
  • Packet Forwarding Use the following C++ statement d->recv(ppt,h)spt ppt dpt packetNsObject NsObject 6 7 www.ns2ultimate.com
  • OUTLINEReview of main packet operationsPacket destruction function• Direct packet destruction (Packet::free(p))• Send to a dropping objectExample packet dropping process 7 www.ns2ultimate.com
  • Packet DestructionWhen• Packets have reached the final destination (inform the application and drop the packet)• Packets are dropped (e.g., buffer overflow)How? ➠ Two methods1.Direct packet destruction: Function Packet::free(p)2.Send the packet to a dropping object 8 www.ns2ultimate.com
  • Example Scenario Suppose an NsObject S just receive a packet Pfrom an NsObject T Let spt, ppt, and tpt be the correspondingpointers tpt ppt spt packet P T NsObject NsObject S 9 www.ns2ultimate.com
  • Example ScenarioAgain the packet forwarding is carried out byinvoking a C++ statement: spt->recv(ppt,h)From within the scope of the NsObject T tpt ppt spt packet P T NsObject NsObject S 10 www.ns2ultimate.com
  • Example ScenarioNow the packet P is inside the NsObject SSuppose S would like to destroy the packet P, thereare two ways: 1. Direct destruction 2. Send the packet to a dropping object spt ppt P NsObject S packet 11 www.ns2ultimate.com
  • the first method: Direct packet destruction 12
  • 1.Direct Packet DestructionUsage: Let S destroy packet P• From within the scope of the class of S• Execute “free(ppt)”Example of S: spt ppt• Agent/Null• Common dropping object NsObject P S packet 13 www.ns2ultimate.com
  • 1.Direct Packet Destruction Null Agent in the NS2 hierarchy base class NsObject Connector bind Agent Agentderived class C++ OTcl Agent/Null domain domain 14 www.ns2ultimate.com
  • 1.Direct Packet DestructionNull agent has no C++ implementation bind Agent Agent Agent/Null C++ OTcl domain domainIt reuses that of the base class, class Agent 15 www.ns2ultimate.com
  • 1.Direct Packet Destruction void Agent::recv(Packet* p, Handler*) { if (app_) app_->recv(hdr_cmn::access(p)->size()); Packet::free(p); }Direct packet dropping: If the application (app_) Regardless of the exists, exists, inform theexistence of application, application of the size ofdestroy the packet using the received packet “free(p)”. 16 www.ns2ultimate.com
  • 1.Direct DestructionRecap: To drop a packet, S can just invoke Packet::free(ppt)From within its scope spt ppt P NsObject S packet 17 www.ns2ultimate.com
  • the second method: Send toa dropping object 18
  • Modifying The ScenarioDo not let S drop the packetLet S send the packet to a dropping object D spt ppt P NsObject S packet 19 www.ns2ultimate.com
  • 2. Send to a dropping object Do not let S drop the packet Let S send the packet to a dropping object D ➠ Execute “dpt->recv(ppt,h)” spt ppt P NsObjectS packet 20 www.ns2ultimate.com
  • 2. Send to a dropping object Do not let S drop the packet Let S send the packet to a dropping object D ➠ Execute “dpt->recv(ppt,h)” D uses the direction packet dropping spt ppt dpt P P NsObject NsObjectS packet packet D 21 www.ns2ultimate.com
  • 2. Send to a dropping object One last question: Q: How do we get “dpt” from the first place? A: We do it though Tcl/OTcl spt ppt dpt NsObject P NsObjectS packet D 22 www.ns2ultimate.com
  • OUTLINEReview of main packet operationsPacket destruction function• Direct packet destruction (Packet::free(p))• Send to a dropping objectExample packet dropping process 23 www.ns2ultimate.com
  • Example: Connector base class Connector connects to NsObject NsObjects. Common examples of Connector connectors are TcpAgent and Droptail (queue). Agent Let’s try to configure dropping for a connector.derived class 24 www.ns2ultimate.com
  • Configuring Dropping Objects Recall the packet dropping topology spt ppt dpt NsObject P NsObjectS packet D 25 www.ns2ultimate.com
  • Configuring Dropping Objects Recall the packet dropping topology Connector contains A pointer drop_ to a dropping object A pointer target_ to the next downstream object spt ppt drop_ NsObject Connector P Connector NsObjectS packet D 26 www.ns2ultimate.com
  • Configuring Dropping Objects Connector architecture [see previous post]100 5 Network Objects Connector NsObject NsObject target_ Upstream Packet forwarding path Downstream NsObject NsObject drop_ class Connector : public NsObject { Packet dropping public: path NsObject Connector(); Packet Dropping NsObject NsObject* target_;Fig. 5.2. Diagram of a connector: The solid arrows represent NsObject* drop_; pointers, while thedotted arrows show packet forwarding and dropping paths. };Program 5.3 Declaration and function recv(p,h) of class Connector 27 www.ns2ultimate.com
  • Configuring Dropping Objects 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 theWhich is exactly NsObject *drop_what we want! 28 www.ns2ultimate.com
  • Configuring Dropping ObjectsSyntax of drop-targetInvoked from the OTcl domain $conn drop-target $drp-objIf $drp-obj exist ➠ set $drp-obj to be adropping object of $connOtherwise, return the dropping object of $conn 29 www.ns2ultimate.com
  • Configuring Dropping Objects Class connector provides an OTcl command drop-target to set the dropping objectvoid Connector::command(int argc, const char*const* argv){ OTcl command if (strcmp(argv[1], "drop-target") == 0) { drop-target drop_ = (NsObject*)TclObject::lookup(argv[2]); ... Store the input in the variable drop_} 30 www.ns2ultimate.com
  • Configuring Dropping Objects Suppose we want • A sending object to S to be an Agent/TCP object • A dropping object D to be a Null Agent object spt ppt drop_ packet P Agent/TCP NsObject Agent/Null NsObjectS D 31 www.ns2ultimate.com
  • Configuring Dropping Objects Here are what we do 1. Create both the object set $s new [Agent/TCP] set $d new[Agent/Null] drop_ Agent/TCP NsObject Agent/Null NsObjectS D 32 www.ns2ultimate.com
  • Configuring Dropping Objects Here are what we do 1. Create both the object set $s new [Agent/TCP] set $d new[Agent/Null] 2. Configure S using “drop-target” $s drop-target $d drop_ Agent/TCP NsObject Agent/Null NsObjectS D 33 www.ns2ultimate.com
  • Configuring Dropping Objects To drop a packet P, execute the following C++ statement from the scope of S drop(ppt); The packet will be forwarded to D for destruction spt ppt drop_ packet P Agent/TCP NsObject Agent/Null NsObjectS D 34 www.ns2ultimate.com
  • 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 rT. Issaraiyakul and E. Hossain, “Introduction to Network Simulator NS2”, Springer 2009 or visit www.ns2ultimate.com 35