ns2 chapter 5. a node is an otcl class, but most of its components are tclobjects. all node...

32
NS2 Chapter 5

Upload: christal-oneal

Post on 14-Jan-2016

230 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

NS2 Chapter 5

Page 2: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address
Page 3: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

A node is an OTcl class, but most of its components are TclObjects.

All node contain at least the following components◦ An address or an id (id_) monotonically increasing by 1 (from initial value

0)

◦ A list of neighbors (neighbor_)◦ A list of agents (agent_)◦ A node type identifier (nodetype_)◦ A routing module

Page 4: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

Figure 5.1 : Structure of a Unicast Node

a label variable instead of a real object

Page 5: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

Figure 5.2 : Internal Structure of a Multicast Node

In order to enable multicast simulation, we need toset ns [new Simulator -multicast on]

Page 6: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address
Page 7: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

Control functions Address and port number management,

unicast routing functions Agent management Adding neighbors

Page 8: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

$node entry is the first element which will handle packets arriving at that node

$node reset will reset all agents at the node

Page 9: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

$node id returns the node number $node agent [port] returns the handle of the

agent at the specified port alloc-port returns the next available port

number add-route <destination id>< TclObject>and

add-routes, are used by unicast routing to add routes to populate the classifier_

(TclObject is the entry of dmux_)

delete-routes{} takes the id, a list of TclObjects, and a reference to the simulator’s nullagent

Page 10: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

init-routing{} sets the instance variable multiPath_ to be equal to the class variable of the same name

intf-changed{} is invoked by the network dynamics code if a link incident on the node changes state

Page 11: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

Procedure attach{} will add the agent to its list of agents_,

[ assign a port number to the agent and set its source address, set the target of the agent to be its (i.e., the node’s) entry{}, and add a pointer to the port demultiplexer at the node (dmux_) to the agent at the corresponding slot in the dmux_ classifier.) ]

detach{} will remove the agent from agents_

Page 12: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

Each node keeps a list of its adjacent neighbors in its instance variable, neighbor_.

Add-neighbor{} adds a neighbor

Neighbors{} returns this list

Page 13: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address
Page 14: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

Simulator::node-config{} accommodates flexible and modular construction of different node definitions within the same base Node class◦ $ns_ node-config -adhocRouting dsdv◦ $ns_ node-config -reset

The config command can be broken down into separate lines◦ $ns_ node-config -addressingType hier◦ $ns_ node-config -macTrace ON

Page 15: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

Table 5.1: Available options for node configuration

Page 16: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

5.4.1 Address Classifiers5.4.2 Multicast Classifiers5.4.3 Multipath Classifier5.4.4 hash Classifier5.4.5 Replicator

Page 17: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

When a node receives a packet, classifier examines the packet’s fields, usually its destination address, and on occasion, its source address

A classifier provides a way to match a packet against some logical criteria and retrieve a reference to another simulation object based on the match results

Page 18: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

class Classifier : public NsObject {public:

~Classifier();void recv(Packet*, Handler* h = 0);

protected:Classifier();void install(int slot, NsObject*);void clear(int slot);virtual int command(int argc, const char*const* argv);virtual int classify(Packet *const) = 0;void alloc(int);NsObject** slot_; /* table that maps slot number to a NsObject */int nslot_;int maxslot_;

};

Page 19: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

When a classifier recv()’s a packet, it hands it to the classify() method. This is defined differently in each type of classifier derived from the base class

The usual format is for the classify() method to determine and return a slot index into the table of slots

Page 20: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

An address classifier is used in supporting unicast packet forwarding

It applies a bitwise shift and mask operation to a packet’s destination address to produce a slot number

The slot number is returned from the classify() method

Page 21: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

The multicast classifier classifies packets according to both source and destination (group) addresses

It maintains a (chained hash) table mapping source/group pairs to slot numbers

Page 22: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

This object is devised to support equal cost multipath forwarding, where the node has multiple equal cost routes to the same destination, and would like to use all of them simultaneously

This object does not look at any field in the packet. With every succeeding packet, it simply returns the next filled slot in round robin fashion

Page 23: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

This object is used to classify a packet as a member of a particular flow

Hash classifiers use a hash table internally to assign packets to flows

Page 24: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

Replicator does not use the classify function

Simply uses the classifier as a table of n slots; it overloads the recv() method to produce n copies of a packet, that are delivered to all n objects referenced in the table

Replicator replicates a packet, one for each entry in its table, and delivers the copies to each of the nodes listed in the table. The last entry in the table gets the “original” packet

Page 25: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

n0 n1

Addr Classifier

Port Classifier

classifier_

dmux_

entry_

Node entry

Unicast Node

Multicast Classifier

classifier_

dmux_

entry_

Node entry

Multicast Node

multiclassifier_

Page 26: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

5.5.1 Routing Module5.5.2 Node Interface

Page 27: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

Routing agent◦ Exchange routing packet with neighbors

Routing logic◦ Uses the information gathered by routing agents (or

the global topology database in the case of static routing) to perform the actual route computation

Classifiers◦ Use the computed routing table to perform packet

forwarding

Page 28: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

Figure 5.3: Interaction among node, routing, mobile

Page 29: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

Declare the C++ part of your routing module

Decide which one you’ll inherit, which one you’ll override, and put the interfaces of your own module.em in OTcl

Page 30: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

Part 1 問題Part 2 Hint

Page 31: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

0

1

2

3

1. 建立上圖的拓樸,節點 0 與節點 3 間做 TCP(FTP) 和 UDP 的傳輸, 由 0 到 3 的傳送,以 nam 顯示出。2. 顯示出節點 2 的 link id3. 在 node2 裡加入一個 replicator classifier 並顯示出。

Page 32: NS2 Chapter 5.  A node is an OTcl class, but most of its components are TclObjects.  All node contain at least the following components ◦ An address

Problem 1 -- 參考 /tcl/ex/simple.tcl

Problem 2 -- 使用內建指令 info or

Simulator instproc node-to-link {ne1 ne2} {????return ?????

}

Problem 3 -- 利用指令 installNext or install 找到所要加的 classifier 後,使用指令去做新增動