nodes as routers and computer hosts - ubc eceteerawat/publications/ns2/10-nodes.pdf · nodes as...
TRANSCRIPT
![Page 1: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/1.jpg)
Nodes as Routers and Nodes as Routers and Nodes as Routers and Nodes as Routers and Nodes as Routers and Nodes as Routers and Computer Hosts Computer Hosts
Nodes as Routers and Nodes as Routers and Computer Hosts Computer Hosts
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 1
![Page 2: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/2.jpg)
Outline• OverviewOverview• Classifier
P Cl ifi• Port Classifier• Hash Classifier• TL Bridge Configuration• RoutingRouting• Summary
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 2
![Page 3: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/3.jpg)
O iOverview• Node functionalityNode functionality
– Router – Computer Hosts
S k t Add ( L 3 ) P t ( L 4 )• Socket = Address ( Layer 3 ) + Port ( Layer 4 )• Select the next hop object based on
– Address ( Router )FTP CBR
Address ( Router )– Port ( Computer host )
FTP CBR
source
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
destination
3
![Page 4: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/4.jpg)
Node Architecture• An NsObject which connects an NsObject toAn NsObject which connects an NsObject to
– Another NsObject = ( )– [Node] More than one NsObject = Classifier
Connector[ ] j
• Router Address classifier• Computer host Port classifierComputer host Port classifier• Internal mechanismC++: ~ns/common/node cc,hC++: ns/common/node.cc,h
• Route/Port configuration OTcl: ~ns/tcl/lib/ns-node.tcl
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
OTcl ns/tcl/lib/ns node.tcl
4
![Page 5: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/5.jpg)
Node Architecture• A composite objectp j
• OTcl domain– classifier_ = Address classifier
d Port classifier
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
– dmux_ = Port classifierBy default, entry_ is the classifier_
5
![Page 6: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/6.jpg)
Node Functionalities• Receive and classify packetsfy p
– Category 1 Target 1– Category 2 Target 2–– …
• Two task– OTcl: Associate categories and targetsg g– C++: Classify packets
• Classification criteria– Destination address Routing– Destination address Routing– Destination port Delivering to transport
layer protocolPriorities Scheduling
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
– Priorities Scheduling
6
![Page 7: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/7.jpg)
OTcl class Node: InstvarsInstvar Meaning
id_ Node ID agents_ List of attached transport layer agents
nn_ Total number of nodesns_ Simulator
dmux_ Demulitplexer or port classifier classifier_ The head address classifier
module_list_ List of enabled routing modules reg_module_ List of registered routing modules
rtnotifList of routing modules which will be notified ofroute updates
_route updates
ptnotif_List of routing modules which will be notified of port attachment/detachment
hook_assoc_ Sequence of the chain of classifiers
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
mod_assoc_Association of classifiers and routing modules, whoseindexes and values are classifiers and the associatedrouting modules, respectively.
7
![Page 8: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/8.jpg)
Outline• OverviewOverview• Classifier
P Cl ifi• Port Classifier• Hash Classifier• TL Bridge Configuration• RoutingRouting• Summary
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 8
![Page 9: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/9.jpg)
Cl ifi O iClassifiers: Overview• Multi-target packet forwarderMult target packet forwarder
target1
target2
l ifi
• Two main discussions:target3
classifier
w m u1. Configuration (i.e., setting classification criteria)2 Internal mechanism
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
2. Internal mechanism
9
![Page 10: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/10.jpg)
Classifier: Internal Mechanism• Recap: ConnectorRecap: Connector
– A single-target packet forwarder– How do we send a packet *p to a connector *u ? u->recv(p,h)
– FW received packets to the attached NsObject(target )( g _)
//~/ns/common/connector.hclass Connector : public NsObject {
... inline void send(Packet* p, Handler* h){target_->recv(p, h);}
};
//~/ns/common/connector.ccvoid Connector::recv(Packet* p, Handler* h){send(p, h);}
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 10
![Page 11: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/11.jpg)
Classifier: Internal Mechanism• Classifier: Multi-target packet forwarderClassifier: Multi target packet forwarder• Main mechanism1 Look at packet header1. Look at packet header2.FW pkts with the same categories to the
same NsObject in the same “slot”j
target1
21
…slot_
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
target2classifier
11
![Page 12: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/12.jpg)
Classifiers: C++ Implementation
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 12
![Page 13: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/13.jpg)
Classifiers: C++ Implementation
Function Meaningrecv(p,h) Receive a packet
i R hi l b f classify(p) Return a matching slot number for packet *p
find(p) Return a matching target for find(p) Return a matching target for packet *p
install(slot,p) Put a pointer p to an NsObject in slot_[slot]
clear(slot) Remove the NsObject installed in slot [slot]
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
slot_[slot]
13
![Page 14: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/14.jpg)
• In principle 2 main tasks:Classifiers: C++ ImplementationIn principle, 2 main tasks:
1. Configuration: – Tell classifier how to classify packetsTell classifier how to classify packets– C++ defines interface for OTcl to do so.
2. Internal mechanism: Classify packetsy pNsObject
classifier
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 14
![Page 15: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/15.jpg)
1 Configuration: Classifiers: C++ Implementation
1. Configuration: – install(slot,p) puts *NSObject in slot_
2. Internal Mechanism– classify(p):
2
1
slot
_
classify(p): Input: packet; Output: slot number
– find(p):
…
Input: packet; Output: NsObject*
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 15
![Page 16: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/16.jpg)
Classifiers::install(slot,NsObject*)• Put an input pointer “*p” in Put an input pointer p in
slot_[slot]
2
1
_ …
slot
slot
…
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
…
p
16
![Page 17: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/17.jpg)
Cl ifi l if ( )• Return the “slot number”
Classifiers::classify(p)Return the slot number corresponding to packet “*p”Implementation in class • Implementation in class Classifier does not make much sense!!sense!!
• Overridden in the derived classes– HashClassifier– PortClassifier
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 17
![Page 18: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/18.jpg)
Cl ifi fi d( )Classifiers::find(p)• Return a pointer to an NsObjectReturn a pointer to an NsObject
corresponding to packet “*p”
Return this pointer (node)
- Return the matching slot number- Defined in the derived class 2
1
slot
_
pointer (node)
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
Def ned n the der ved class …
packet
18
![Page 19: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/19.jpg)
Cl ifi ( h)Classifiers::recv(p,h)
(1)
(2)
1. Locate an NsObjectdi t k t corresponding to packet
“*p” (using “find(p)”)2. Forward the packet to the 2
1
slot
_Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
2. o wa d the packet to the located NsObject
…
packet
19
![Page 20: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/20.jpg)
Classifiers: OTcl Implementation• Purpose: Configure a classifier Purpose: Configure a classifier Put NsObjects in the slots R t i Retrieve NsObject
• These are OTcl commands in file ns/classifier/classifier cc
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
~ns/classifier/classifier.cc
20
![Page 21: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/21.jpg)
Cl ifi Th Si l tiClassifiers: The Simulation• At the Network Configuration phase
– Define classification criterion– Configure (put NsObject* in slot_)
accordinglyAt th Si l ti h• At the Simulation phase– Receive packet: recv(p,h)
1 “ l ssif ” th k t * d 1. “classify” the packet *p, and 2. forward the packet the matched NsObject
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
NsObject
21
![Page 22: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/22.jpg)
Cl ifi 2 M i TClassifiers: 2 Main Types• A node acts as A node acts as
– A computer host Port classifier PortClassifier
– RouterAddress classifier HashClassifier
• 2 Main tasks:– Configuration– Internal mechanism
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 22
![Page 23: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/23.jpg)
Outline• OverviewOverview• Classifier
P Cl ifi• Port Classifier• Hash Classifier• TL Bridge Configuration• RoutingRouting• Summary
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 23
![Page 24: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/24.jpg)
P Cl ifi O iPort Classifier: Overview• A computer host A computer host
– connects a node to transport layer (TL) protocol
– may have several attached TL protocol• Port: Identify which TL protocol should a
k packet be forwarded to, e.g., – Attach FTP to port 65, and
Att h CBR t t 66FTPCBR
– Attach CBR to port 66Port65Port66
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
Node
24
![Page 25: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/25.jpg)
Port Classifier: NS2 Implementation• Node ConfigurationNode Configuration
• PortClassifier object = dmux_
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 25
![Page 26: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/26.jpg)
• NS2 ConfigurationPort Classifier: NS2 Implementation
NS2 Configuration• Installer a pointer to
agent of portagent of port– 65 in slot_[65]– 66 in slot_[66]
t i l t [ t]– pt in slot_[pt]
FTPCBR
Port65Port66 Port65
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
Node Port66
26
![Page 27: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/27.jpg)
• C++ Implementation
Port Classifier: NS2 ImplementationC Implementation
• PortClassifier::classify(p)(1)
(3)//~ns/classifier/classifier-port.ccint PortClassifier::classify(Packet *p){
hdr ip* iph = hdr ip::access(p);
(3)
hdr_ip* iph = hdr_ip::access(p);return iph->dport();
}
(2)
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
(2)
27
![Page 28: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/28.jpg)
Outline• OverviewOverview• Classifier
P Cl ifi• Port Classifier• Hash Classifier• TL Bridge Configuration• RoutingRouting• Summary
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 28
![Page 29: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/29.jpg)
H h Cl ifiHash Classifier• Hash determinitically digests an Hash determinitically digests an
input and spits out an outputHASH
(function)Input Output
• Same input always hashes to the same outputp
• Example: – Encryption: MD5 SHA-256
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
Encryption: MD5, SHA 256– Look up table
29
![Page 30: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/30.jpg)
H h Cl ifi E lHash Classifier: Example• Look up table: Sequential search takes Look up table: Sequential search takes
long time• Input = 4 bits
Input Output0 10Input = 4 bits
• Output = 4 bitsH h f
0 101 11
• Hash function = XOR with 1010
2 43 9
• Much quicker operation 4 45 15
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
6 1230
![Page 31: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/31.jpg)
H h Cl ifiHash Classifier• In NS2: Hash tableIn NS2: Hash table
Slot Flow ID SRC dd
DST ddno. address address
0 10 2 3
• Input = (hash) key = (fid src dst)
1 11 4 7
Input = (hash) key = (fid,src,dst)• Output = (hash) index = slot no.
E h h h dTextbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
• Each row = hash record31
![Page 32: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/32.jpg)
H h Cl ifiHash Classifier• Base C++ class = HashClassifierBase C++ class = HashClassifier• 4 main derived classes:
C++ Class OTcl Class Classification criteria
D tH hCl ifi Cl ifi / (d )DestHashClassifier Classifier/Hash/Dest
(dst)
FidHashClassifier Classifier/Hash/Fid
(fid)
• Input = (hash) key = (fid,src,dst)O (h h) i d l
Hash/Fid
SrcDestHashClassifier Classifier/Hash/SrcDest
(src,dst)
SrcDestFidHashClassifier Classifier/ ( d t fid)
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
• Output = (hash) index = slot no.SrcDestFidHashClassifier Classifier/Hash/SrcDestFid
(src,dst,fid)
32
![Page 33: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/33.jpg)
D H hCl ifiDestHashClassifier• No need to define function recv(p h)No need to define function recv(p,h)• Define function classify(p)://~ns/classifier/classifier-hash cc//~ns/classifier/classifier-hash.ccint DestHashClassifier::classify(Packet * p) {
int slot = lookup(p); if (slot >= 0 && slot <=maxslot )
Defined in classH hCl ifiif (slot >= 0 && slot <=maxslot_)
return (slot); else if (default_ >= 0)
return (default );
HashClassifier
return (default_); else return (-1);
}
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 33
![Page 34: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/34.jpg)
Outline• OverviewOverview• Classifier
P Cl ifi• Port Classifier• Hash Classifier• TL Bridge Configuration• RoutingRouting• Summary
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 34
![Page 35: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/35.jpg)
C fi i Cl ifiConfiguring Classifier• Classifier forwards packet to a Classifier forwards packet to a
predefines categories Internal mechanism Internal mechanism
• How are the categories predefined?f Configuration
• TL bridges PortClassifierg• Routers DestHashClassifier
• Mainly in OTcl
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
• Mainly in OTcl
35
![Page 36: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/36.jpg)
C fi i P Cl ifiConfiguring PortClassifier• Recall: instproc attach-agent of class Recall: instproc attach-agent of class Simulator
1. $ns attach-agent $node $agentg g2. $node attach $agent {port “”}3. $node add-target $agent $port4. $rm attach $agent $portg p5. $agent target [[$self node] entry]5. [[$self node] demux] install $port $agent
Note: $rm is a routing module stored in the array ptnotif of $node
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
ptnotif_ of $node
36
![Page 37: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/37.jpg)
C fi i P Cl ifiConfiguring PortClassifier//~ns/tcl/lib/ns-lib.tcl Si l t i t tt h t { d t } {Simulator instproc attach-agent { node agent } {
$node attach $agent } //~ns/tcl/lib/ns-node.tcl
(2)
Node instproc attach { agent { port "" } } { $self instvar agents_ address_ dmux_ ...$self add-target $agent $port (3)
} Node instproc add-target { agent port } {
$self instvar ptnotif_ foreach m [$self set ptnotif_] {
$m attach $agent $port (4)$ $ g $p}
} //~ns/tcl/lib/ns-rtmodule.tcl RtModule instproc attach { agent port } {
$agent target [[$self node] entry]
(4)
(5)
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
$agent target [[$self node] entry] [[$self node] demux] install $port $agent
}
(5)(5)
37
![Page 38: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/38.jpg)
Configuring PortClassifier$agent target [[$self node] entry]$ g g [[$ ] y]
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 38
![Page 39: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/39.jpg)
Configuring PortClassifier[[$self node] demux] install $port $agent[[$ ] ] $p $ g
2
1
_ …
slot
_slot
…
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
…
p
39
![Page 40: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/40.jpg)
Configuring D H hCl ifiDestHashClassifier
• Address classifierAddress classifier
R h h bj f • Return the next hop object for a given destination address
• RoutingRout ng
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 40
![Page 41: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/41.jpg)
Outline• OverviewOverview• Classifier
P Cl ifi• Port Classifier• Hash Classifier• TL Bridge Configuration• RoutingRouting• Summary
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 41
![Page 42: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/42.jpg)
R i (O li )• A routing protocol consists of 4 main
Routing (Outline)A routing protocol consists of 4 main components:
– Routing agent: Information collector (not g g (being used for static routing)
– Route logic: Routing table computationCl ifi P k f d (b h – Classifier: Packet forwarder (base on the route logic)
– Routing module: The single point of Routing module: The single point of management for classifiers
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 42
![Page 43: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/43.jpg)
R iRouting• Relationship among routing componentsRelationship among routing components
attach-agent SIMULATORattach agent
NODE
CLASSIFIERROUTING MODULErtmodule_, ptnotif_
newattachadd-route
installregisterattachadd-route
computeconfigure
ROUTE LOGIC
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 43
![Page 44: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/44.jpg)
R L i• Compute routing table
Route LogicCompute routing table
• How? Based on predefined routing protocol, e.g.,protocol, e.g.,– Agent/rtProto/Static– Agent/rtProto/Manual– Agent/rtProto/DV
• C++ and OTcl classes RouteLogic • Consider Agent/rtProto/Static– Simulator knows the topology
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
– Let Simulator computes the routing table
44
![Page 45: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/45.jpg)
C Cl R L i• C++ main variables (~ns/routing/route *)
C++ Class RouteLogicC++ main variables ( ns/routing/route. )
– adj_: Adjacency matrix– route : routing table_ g
• C++ main functionsFunctions Meaninginsert(src,dst) Insert an entry (src,dst) to the
adjacency matrix adjadjacency matrix adj_compute_routes() Use adj_ to compute the routing table
and store it in route_l k fl ( id did) R t th f di bj t f
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
lookup_flat(sid,did) Return the forwarding object for a route from sid to did
45
![Page 46: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/46.jpg)
OT l Cl R L i• One OTcl main variables
OTcl Class RouteLogicOne OTcl main variables
• An array rtprotos_i d Th f ti t l – index = The name of a routing protocol (e.g., Static, Manual)
l Th ti t l t– value = The routing protocol agent• See file ~ns/tcl/lib/ns-route.tcl
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 46
![Page 47: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/47.jpg)
OT l Cl R L i• OTcl main functions
OTcl Class RouteLogicOTcl main functions
Functions Meaningi t { t} St th ti t l t t i register{name,agent} Store the routing protocol agent <agent> in
rtprotos_[<name>]
configure{} Initialize all its routing protocol inrtprotos by invoking their instproc init-rtprotos_ by invoking their instproc init-all{}
lookup{sid,did} Return the forwarding object for a route from (sid,did)( , )
compute{} Invoke the C++ function compute_routes()
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
In file ~ns/tcl/lib/ns-route.tcl
47
![Page 48: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/48.jpg)
OT l Cl R L i• Default Routing protocol: Static
OTcl Class RouteLogicDefault Routing protocol Static
• Instproc configure{}RouteLogic instproc configure {} {
$self instvar rtprotos $se st a tp otos_if [info exists rtprotos_] {
foreach proto [array names rtprotos_] { eval Agent/rtProto/$proto init-all $rtprotos_($proto)
}} } else {
Agent/rtProto/Static init-all }
}}
• If another routing protocol exist, it will be in charge of route computation, e.g.,
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
– Set the adj_ of the RouteLogic– Compute the routing table.
48
![Page 49: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/49.jpg)
R L i C fi iRoute Logic Configuration• Setting a routing tableSetting a routing table• Start when “ $ns run ” is executed.
U Dijk h h l i h • Use Dijkstar shortest path algorithm for all pairs of nodes
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 49
![Page 50: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/50.jpg)
R L i C fi iRoute Logic Configuration• Default route logic setupDefault route logic setup1. $ns run2. [$ns get-routelogic] configure3 A t/ tP t /St ti i it ll3. Agent/rtProto/Static init-all4. $ns compute-routes5. $ns compute-flat-routes6. set r [$ns get-routelogic]
foreach ln [array names link_] { $r insert $srcID $dstID [$link ($ln) cost?]$ $ $ [$ _($ ) ]
}$r compute
Go through NS2 codes yourself!!
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
Go through NS2 codes yourself!!
50
![Page 51: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/51.jpg)
R i• A routing protocol consists of 4 main
RoutingA routing protocol consists of 4 main components:
– Routing agent: Information collector (not g g (being used for static routing)
– Route logic: Routing table computationCl ifi P k f d (b h – Classifier: Packet forwarder (base on the route logic)
– Routing module: The single point of Routing module: The single point of management for classifiers
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 51
![Page 52: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/52.jpg)
Cl ifi d R i• Two main configuration tasks
Classifier and RoutingTwo main configuration tasks
1. Putting classifiers in Nodes2. Configuring the classifiers g g
• Configuring the route logic1. $ns run
…5. $ns compute-flat-routes6. … $r compute$ p7. $self populate-flat-classifiers [Node set nn_]8. [C++] Simulator::populate_flat_classifiers()
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 52
![Page 53: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/53.jpg)
C fi i Cl ifi//~ns/common/simulator.cc void
Configuring a ClassifierSimulator::populate_flat_classifiers() {
... for (int i=0; i<nn_; i++) {
for (int j 0; j<nn ; j++) {
A pointer to a RouteLogicobject
for (int j=0; j<nn_; j++) { if (i != j) {
int nh = -1; nh = rtobject ->lookup flat(i, j); j _ p_ ( , j);if (nh >= 0) {
NsObject *l_head = get_link_head(nodelist_[i],nh);sprintf(tmp, "%d", j); nodelist_[i]->add_route(tmp, l_head);
} }
}
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
} }
}
53
![Page 54: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/54.jpg)
C fi i Cl ifi//~ns/common/node.cc
Configuring a Classifiervoid Node::add_route(char *dst, NsObject *target) {
if (rtnotif_) rtnotif_->add_route(dst, target);
}
A pointer to a RoutingModule object
• We shall discuss the routing module later.• For now, it’s sufficient to know that, ff“A packet bound to dst should be FW to target”
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 54
![Page 55: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/55.jpg)
P i Cl ifi i N d• Two main configuration tasks
Putting a Classifier in a Node• Two main configuration tasks
1. Putting classifiers in Nodes2. Configuring the classifiers 2. Configuring the classifiers
• From the constructor of class Node1. $ns node2. set node [new Node]3. $node init4. $node mk-default-classifier5 $node register-module [new RtModule/Base]
Q: Why invoking init{} ? What is init{}?
5. $node register module [new RtModule/Base]6. RtModule/Base register $node7. set classifier_ [new Classifier/Hash/Dest/ 32]7. $node install-entry RtModule/Base $classifier_
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
• Go through the NS2 codes by yourself.55
![Page 56: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/56.jpg)
I lli Cl ifi i N d• We can have several classifiers in a node
Installing Classifiers in a Node• We can have several classifiers in a node.
• This example has 2 classifiers.
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 56
![Page 57: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/57.jpg)
I lli Cl ifi i N d• We can have several classifiers in a node
Installing Classifiers in a Node• We can have several classifiers in a node. Chain of Classifiers
classifier2 3 4
_(_o1) _o2 _o3 _o4
hook_assoc_
Routing Routing Routing Routing mod_assoc_
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
RoutingModule
RoutingModule
RoutingModule
RoutingModule
_o5 _o6 _o7 _o857
![Page 58: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/58.jpg)
OTcl class Node: InstvarsInstvar Meaning
id_ Node ID agents_ List of attached transport layer agents
nn_ Total number of nodes_
ns_ Simulator dmux_ Demulitplexer or port classifier
classifier_ The head address classifiermodule_list_ List of enabled routing modules reg_module_ List of registered routing modules
rtnotifList of routing modules which will be notified ofroute updates
_route updates
ptnotif_List of routing modules which will be notified of port attachment/detachment
hook_assoc_ Sequence of the chain of classifiers
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
mod_assoc_Association of classifiers and routing modules, whoseindexes and values are classifiers and the associatedrouting modules, respectively.
58
![Page 59: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/59.jpg)
I lli Cl ifi i N d• Maintain the head classifier (classifier )
Installing Classifiers in a NodeMaintain the head classifier (classifier_) only.
• Access other classifiers through Access other classifiers through classifier_.
Instvar Index Valuehook_assoc_ A classifier The next
classifiermod_assoc_ A classifier The associated
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
routing module
59
![Page 60: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/60.jpg)
I lli Cl ifi i N d• Example values
Installing Classifiers in a Node• Example values
_o1 _o2 _o3 _o4
Routing Routing Routing RoutingRoutingModule
RoutingModule
RoutingModule
RoutingModule
_o5 _o6 _o7 _o8
• mod_assoc_[_o1] = _o5• mod_assoc_[_o2] = _o6• mod_assoc_[_o3] = _o7
08
• hook_assoc_[_o1] = _o2• hook_assoc_[_o2] = _o3• hook assoc [ o3] = o4
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
• mod_assoc_[_o4] = _08hook_assoc_[_o3] _o4
60
![Page 61: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/61.jpg)
I lli Cl ifi i N d• Three main instprocs:
Installing Classifiers in a NodeThree main instprocs:
1. insert-entry{ module clsfr {hook “”}}a. Associate the classifier clsfr with the routing module
module, b. Put clsfr as the head classifier, c. If hook is a number, put the next (previously the head) p p y
classifier in the slot hook of clsfrd. If hook is “target”, set the target of clsfr to be the next
(previously the head) classifierp y
2. install-entry{ module clsfr {hook “”}} (also destroy the head classifier if any)
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
destroy the head classifier, if any)
61
![Page 62: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/62.jpg)
I lli Cl ifi i N d//~ns/tcl/lib/ns-node.tcl
Installing Classifiers in a NodeNode instproc insert-entry { module clsfr {hook ""} } {
$self instvar classifier_ mod_assoc_ hook_assoc_ if { $hook != "" } {
$ $set hook_assoc_($clsfr) $classifier_if { $hook == "target" } {
$clsfr target $classifier_ } elseif { $hook != "" } {
(d)} elseif { $hook ! } {
$clsfr install $hook $classifier_}
}
(c)
set mod_assoc_($clsfr) $module set classifier_ $clsfr
}
(a)(b)
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
• Go through instproc install-entry{…} yourself.
62
![Page 63: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/63.jpg)
I lli Cl ifi i N d3 {install-demux { demux {port “”}}
Installing Classifiers in a Node3. {install demux { demux {port }}
a. Replace the current dmux_ with the input demuxb If port exists put the current dmux in the slot b. If port exists, put the current dmux_ in the slot
port of the input dmux//~ns/tcl/lib/ns-node.tclNode instproc install-demux {demux {port ""} } {Node instproc install demux {demux {port } } {
$self instvar dmux_ address_if { $dmux_ != "" } {
$self delete-route $dmux_if { $port != "" } {if { $port != } {
$demux install $port $dmux_}
}t d $d (a)
(b)
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
set dmux_ $demux$self add-route $address_ $dmux_
}
(a)
63
![Page 64: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/64.jpg)
R i• A routing protocol consists of 4 main
RoutingA routing protocol consists of 4 main components:
– Routing agent: Information collector (not g g (being used for static routing)
– Route logic: Routing table computationCl ifi P k f d (b h – Classifier: Packet forwarder (base on the route logic)
– Routing module: The single point of Routing module: The single point of management for classifiers
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 64
![Page 65: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/65.jpg)
M i iMotivation• In general, we can have several classifiers.g
_o1 _o2 _o3 _o4
• Suppose we want to send a common command (e.g., add-route, attach-agent) to all classifiers
Sequentially access each of classifiers– Sequentially access each of classifiers– Send a command (e.g., add-route) to the accessed classifier
• It would be more convenient if we can have a classifier managermanager.– Send the command to this manager.– The manager will auto. access and populate the command.
Thi i ll d “ROUTING MODULE”
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
• This manager is called a “ROUTING MODULE”
65
![Page 66: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/66.jpg)
I l i R i M d lImplementing Routing Module• Objective: Manage classifiersObjective Manage classifiers• Where do we need to manage it? Node• Place two “classifier managers” in class Node
Classifier manager (i.e., routing module) ptnotif_ rtnotif_( . ., g m )Managed Functionality TL bridge Routing
Type of classifiers Port AddressManagement List based Pointer based
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
Technique List based Pointer based
66
![Page 67: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/67.jpg)
OTcl class Node: InstvarsInstvar Meaning
id_ Node ID agents_ List of attached transport layer agents
nn_ Total number of nodes_
ns_ Simulator dmux_ Demulitplexer or port classifier
classifier_ The head address classifiermodule_list_ List of enabled routing modules reg_module_ List of registered routing modules
rtnotif_List of routing modules which will be notified ofroute updates
_route updates
ptnotif_List of routing modules which will be notified of port attachment/detachment
hook_assoc_ Sequence of the chain of classifiers
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
mod_assoc_Association of classifiers and routing modules, whoseindexes and values are classifiers and the associatedrouting modules, respectively.
67
![Page 68: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/68.jpg)
R i M d l DiRouting Module Diagramrtnotif_ ptnotif_
...
Node$rtnotif_ add-route
$addr $target
next_rtm_
RM
0next_rtm_
RM
... 0next_rtm_
RM
0next_rtm_
RM
...
Agent
classifier_ classifier_ classifier_ classifier_
foreach m {ptnotif_} {$m attach $agent $portAgent
Agent
AddressClassifier
Addressclassifier
PortClassifier
Agent
$m attach $agent $port}
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
Link
Classifier classifier
Agent
PortClassifier
68
![Page 69: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/69.jpg)
R i M d l CRouting Module: C++• C++ class RoutingModule bound toC++ class RoutingModule, bound to• OTcl class RtModule Add/remove a
routing module //~ns/routing/rtmodule.hclass RoutingModule : public TclObject { public:
g*rtm to the chain
void route_notify(RoutingModule *rtm); void unreg_route_notify(RoutingModule *rtm); virtual void add_route(char *dst, NsObject *target); i i jvirtual void delete_route(char *dst, NsObject *nullagent);
RoutingModule *next_rtm_; protected:
Classifier *classifier ;
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
Classifier classifier_; }; Add/remove a pointer *target into the classifier_
associated with all downstream Routing Module69
![Page 70: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/70.jpg)
R i M d l CRouting Module: C++//~ns/routing/rtmodule.cc void RoutingModule::route_notify(RoutingModule *rtm) {
if (next_rtm_ != NULL) next_rtm_->route_notify(rtm);
elseelse next_rtm_ = rtm;
} void RoutingModule::add route(char *dst, NsObject *target) g _ ( , j g ){
if (classifier_) classifier_->do_install(dst,target);
if (next_rtm_ != NULL) next_rtm_->add_route(dst, target);
}• Function add route(…) eliminate the needs to
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
Function add_route(…) eliminate the needs to 1. Get an access to each classifier2. Invoke do_install(…) for each of them
70
![Page 71: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/71.jpg)
R i M d l OT lRouting Module: OTcl• Class RtModule bound to the C++ class Class RtModule bound to the C++ class RoutingModule
• Two key instvars: ne t rtm • Two key instvars: next_rtm_, classifier_
F i • Few instprocs:
register{node} unregister{}register{node} unregister{}route-notify{mod} un-reg-route-notify{mod}add-route{dst,target} delete-route{dst,nullagent}attach{agent port} attach-node{node}
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
attach{agent,port} attach node{node}
71
![Page 72: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/72.jpg)
Sample Derived Classes
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 72
![Page 73: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/73.jpg)
OTcl class Node: InstvarsInstvar Meaning
id_ Node ID agents_ List of attached transport layer agents
nn_ Total number of nodes_
ns_ Simulator dmux_ Demulitplexer or port classifier
classifier_ The head address classifiermodule_list_ List of enabled routing modules reg_module_ List of registered routing modules
rtnotif_List of routing modules which will be notified ofroute updates
_route updates
ptnotif_List of routing modules which will be notified of port attachment/detachment
hook_assoc_ Sequence of the chain of classifiers
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
mod_assoc_Association of classifiers and routing modules, whoseindexes and values are classifiers and the associatedrouting modules, respectively.
73
![Page 74: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/74.jpg)
Node Instvars• module list stores the name of enabled routing modules._ _ g• Instproc mk-default-classifier registers routing
modules whose name is in the module_list_.
• reg_module_ (associated array)– Index: Routing module’s name– Value: Routing module’s instance– Value: Routing module s instance
• rtnotif_: The head of routing modulet tif : An array f r utin m dule (f r p rt • ptnotif_: An array of routing module (for port
attachment)
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 74
![Page 75: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/75.jpg)
Related Routing Module ComponentsThis configurationis created when a Node is created“$ d ”“$ns node”
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
module_list_={Base,Mcast}
75
![Page 76: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/76.jpg)
N d Obj C iNode Object Creation• Suppose we have a node $node and Suppose we have a node, $node, and
a base routing module, $base. 1 At compilation1. At compilation//~/ns/tcl/lib/ns-node.tclNode set module_list_ { Base }
2. Node Construction: $ns node21 Node constructor: Node init {}21. Node constructor: Node init {}21-1. set rtnotif_ {}21-2. set ptnotif {}
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
p _ {}
21-3. $node mk-default-classifier
76
![Page 77: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/77.jpg)
N d Obj C iNode Object Creation
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 77
![Page 78: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/78.jpg)
N d Obj C iNode Object Creation
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 78
![Page 79: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/79.jpg)
N d Obj C iNode Object Creation213. $node mk-default-classifier
213-1. foreach modname [Node set module_list_] { $node register-module [new RtModule/$modname]
}
2131 [Node instproc register-module { base }]2131-1 $base $register $node2131-2 set reg_module_([$base module-name]) $base
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 79
![Page 80: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/80.jpg)
N d Obj C iNode Object Creation
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 80
![Page 81: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/81.jpg)
N d Obj C iNode Object Creation21311 $base $register $node21311-1 RtModule register $node23111-2 RtModule/Base register $node
213111 RtModule register $node213111-1 $base attach-node $node213111-2 $node route-notify $base213111-3 $node port-notify $base
2131111 $base attach-node $node (OTcl command)2131111-1 n_ = (Node*)TclObject::lookup(argv[2]);
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 81
![Page 82: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/82.jpg)
N d Obj C iNode Object Creation
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 82
![Page 83: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/83.jpg)
N d Obj C iNode Object Creation2131112 $node route-notify $base//~/ns/tcl/lib/ns-node.tclNode instproc route-notify { module } {
$self instvar rtnotif_ if {$rtnotif_ == ""} {
set rtnotif_ $module (2131112-1)} else {
$rtnotif_ route-notify $module (2131112-2)} $module cmd route-notify $self (2131112-3)
}
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 83
![Page 84: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/84.jpg)
N d Obj C iNode Object Creation
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 84
![Page 85: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/85.jpg)
N d Obj C iNode Object Creation21311122 $rtnotif_ route-notify $module //~/ns/tcl/lib/ns-rtmodule.tclRtModule instproc route-notify { module } {
$self instvar next_rtm_ if {$next_rtm_ == ""} {
set next_rtm_ $module} else {
Consider RtModule/Mcast
$next_rtm_ route-notify $module}
}
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 85
![Page 86: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/86.jpg)
N d Obj C iNode Object Creation
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 86
![Page 87: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/87.jpg)
N d Obj C iNode Object Creation2131112 $node route-notify $base//~/ns/tcl/lib/ns-node.tclNode instproc route-notify { module } {
$self instvar rtnotif_ if {$rtnotif_ == ""} {
set rtnotif_ $module (2131112-1) } else {
$rtnotif_ route-notify $module (2131112-2)} $module cmd route-notify $self (2131112-3)
}
What ‘s difference?
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
What s difference?
87
![Page 88: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/88.jpg)
N d Obj C iNode Object Creation2131112-3 $module cmd route-notify $self (OTcl command)21311123-1 (Class RoutingModule) n_->route_notify(this);
void Node::route_notify(RoutingModule *rtm) {if (rtnotif_ == NULL)
rtnotif_ = rtm;else
t tif > t tif ( t )rtnotif_->route_notify(rtm);}//~ns/routing/rtmodule.cc void RoutingModule::route notify(RoutingModule *rtm) { g _ y( g ) {
if (next_rtm_ != NULL) next_rtm_->route_notify(rtm);
else
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
next_rtm_ = rtm; }
88
![Page 89: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/89.jpg)
N d Obj C iNode Object Creation
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 89
![Page 90: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/90.jpg)
N d Obj C iNode Object Creation
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 90
![Page 91: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/91.jpg)
N d Obj C iNode Object Creation21311 $base $register $node21311-1 RtModule register $node23111-2 RtModule/Base register $node
213111 RtModule register $node213111-1 $base attach-node $node213111-2 $node route-notify $base213111-3 $node port-notify $base
//~/ns/tcl/lib/ns-node.tclNode instproc port-notify { module } {
$self instvar ptnotif_ lappend ptnotif $module
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
_}
91
![Page 92: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/92.jpg)
N d Obj C iNode Object Creation21311 $base $register $node21311-1 RtModule register $node23111-2 RtModule/Base register $node
//~/ns/tcl/lib/ns-rtmodule.tclRtModule/Base instproc register { node } {
$self next $node$self instvar classifier_set classifier_ [new Classifier/Hash/Dest 32]$classifier_ set mask_ [AddrParams NodeMask 1]_ _$classifier_ set shift_ [AddrParams NodeShift 1]$node install-entry $self $classifier_
}
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 92
![Page 93: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/93.jpg)
N d Obj C iNode Object Creation
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 93
![Page 94: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/94.jpg)
N d Obj C iNode Object Creation21311 $base $register $node21311-1 RtModule register $node23111-2 RtModule/Mcast register $node
//~/ns/tcl/lib/ns-rtmodule.tclRtModule/Mcast instproc register { node } {
$node set switch_ [new Classifier/Addr]$node insert-entry $self [$node set switch_] 0
}
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 94
![Page 95: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/95.jpg)
Th U f R i M d lThe Use of Routing Modules• Why is it so complicated? Why is it so complicated? • Suppose you remove a routing module,
you will have you will have
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 95
![Page 96: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/96.jpg)
Th U f R i M d l• Why is it so complicated? The Use of Routing ModulesWhy is it so complicated?
• Suppose you remove a routing module, you will haveyou will have
• Isn’t it nice?
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 96
![Page 97: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/97.jpg)
Th U f R i M d l• How would you add-route/attach agent to
The Use of Routing ModulesHow would you add route/attach agent to the node?
• Access and send commands to each Access and send commands to each classifier manually.
• What if you have 10 classifiers for each f y f fnode?
• What if you are implementing dynamic y p g yrouting?
• NOT SCALABLE !!!
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 97
![Page 98: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/98.jpg)
Th U f R i M d l• Two routing modules The Use of Routing ModulesTwo routing modules 1. ptnotif_ (List): Control TL bridges2 rtnotif (Pointer): Control Routing2. rtnotif_ (Pointer): Control Routing
• Recall: Agent attachment– $ns attach-agent $node $udp
//~ns/tcl/lib/ns-node.tclNode instproc attach { agent { port "" } } {
if { $dmux_ == "" } { set dmux_ [new Classifier/Port] $self add-route $address_ $dmux_
}
rtnotif_
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
} $self add-target $agent $port
}ptnotif_
98
![Page 99: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/99.jpg)
Th U f R i M d l//~ns/tcl/lib/ns-lib.tcl Si l t i t tt h t { d t } {
The Use of Routing ModulesSimulator instproc attach-agent { node agent } {
$node attach $agent } //~ns/tcl/lib/ns-node.tcl
(2)
Node instproc attach { agent { port "" } } { $self instvar agents_ address_ dmux_ ...$self add-target $agent $port (3)
} Node instproc add-target { agent port } {
$self instvar ptnotif_ foreach m [$self set ptnotif_] {
$m attach $agent $port (4)Access the demultiplexer $ $ g $p}
} //~ns/tcl/lib/ns-rtmodule.tcl RtModule instproc attach { agent port } {
$agent target [[$self node] entry]
(4)
(5)
Access the demultiplexer through ptnotif_
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
$agent target [[$self node] entry] [[$self node] demux] install $port $agent
}
(5)(5)
99
![Page 100: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/100.jpg)
Th U f R i M d l//~ns/tcl/lib/ns-node.tcl
The Use of Routing ModulesNode instproc add-route { dst target } {
$self instvar rtnotif_ if {$rtnotif_ != ""} {
$rtnotif add ro te $dst $target$rtnotif_ add-route $dst $target } $self incr-rtgtable-size
} }
//~ns/tcl/lib/ns-rtmodule.tclRtModule instproc add-route { dst target } { Access classifier_
through rtnotif$self instvar next_rtm_ [$self set classifier_] install $dst $targetif {$next_rtm_ != ""} {
$next rtm add route $dst $target
through rtnotif_
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
$next_rtm_ add-route $dst $target}
}
100
![Page 101: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/101.jpg)
Th U f R i M d l//~ns/tcl/lib/ns-node.tcl
The Use of Routing ModulesNode instproc add-route { dst target } {
$self instvar rtnotif_ if {$rtnotif_ != ""} {
$rtnotif add ro te $dst $target$rtnotif_ add-route $dst $target } $self incr-rtgtable-size
} }
//~ns/tcl/lib/ns-rtmodule.tclRtModule instproc add-route { dst target } { Access classifier_
through rtnotif$self instvar next_rtm_ [$self set classifier_] install $dst $targetif {$next_rtm_ != ""} {
$next rtm add route $dst $target
through rtnotif_
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
$next_rtm_ add-route $dst $target}
}
101
![Page 102: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/102.jpg)
Outline• OverviewOverview• Classifier
P Cl ifi• Port Classifier• Hash Classifier• TL Bridge Configuration• RoutingRouting• Summary
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 102
![Page 103: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/103.jpg)
SummaryN d F ti lit • Node Functionality – ( Router ) and ( Computer Host )– Consists of connectors and classifiers
• Classifiers– Multi-target connector– Router ( Address classifier )( )– Computer host ( Port classifier )
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 103
![Page 104: Nodes as Routers and Computer Hosts - UBC ECEteerawat/publications/NS2/10-Nodes.pdf · Nodes as Routers and Computer Hosts Textbook: ... 3.$node add-target $agent $port 4.$rm attach](https://reader031.vdocuments.us/reader031/viewer/2022022419/5a78ddff7f8b9a5a148ce18b/html5/thumbnails/104.jpg)
Summary• Routing Components• Routing Components
1. ( Routing agent )2. ( Route logic )3. ( Classifier )4. ( Routing module )
• Node configuration: 3 main steps1. Node construction Command: ( $ns node )2. Route configuration Command: ( $ns run )3. TL Bridge configuration Command:
( $ns attach-agent $node $agent )
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
( $ns attach agent $node $agent )
104