NS2 defines applications in class Application (see ~ns/apps/app.h,cc). The derive classes of application are for example TrafficGenerator (e.g., CBR) or FTP. The application models user demand. Therefore it need to send message to an agent saying that a use needs to send data. Here is how.
Class Application have a pointer to an Agent object, agent_. In order to send a message with size nbyte bytes to an associated agent. It executes
agent->sendmsg(nbytes);
where the function sendmsg(...) belongs to class Agent. There are several more ways that an Agent object can received a message. Those ways are defined in function of class Agent (see ~ns/common/agent.cc).
For more information about Agents and Applications, see Chapters 9-11 in the following book from Springer:
T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator NS2", Springer 2008.
http://www.springer.com/engineering/signals/book/978-0-387-71759-3
You may also find the following website useful:
http://www.ece.ubc.ca/~teerawat/NS2.htm
Wednesday, April 29, 2009
Friday, March 13, 2009
[NS2] Dropping a Packet
Suppose you have a pointer "p". You can drop the packet by executing
Note that "drop(p)" is a function of class Connector, and therefore must be invoked from within the scope of class Connector.
For more information about Connector and Packet, see Chapters 5 and 8, respectively, in the following book from Springer:
T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator NS2", Springer 2008.
http://www.springer.com/engineering/signals/book/978-0-387-71759-3
You may also find the following website useful:
http://www.ece.ubc.ca/~teerawat/NS2.htm
Also the packet "*p" can be dropped from within the Connector object by invoking function drop as follows:
Packet::free(p)
drop(p);
Note that "drop(p)" is a function of class Connector, and therefore must be invoked from within the scope of class Connector.
For more information about Connector and Packet, see Chapters 5 and 8, respectively, in the following book from Springer:
T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator NS2", Springer 2008.
http://www.springer.com/engineering/signals/book/978-0-387-71759-3
You may also find the following website useful:
http://www.ece.ubc.ca/~teerawat/NS2.htm
Wednesday, March 11, 2009
"no-slot" error for classifiers
"no-slot" error for classifiers
From previous post, a classifier is a multi-target packet forwarder. It classifies incoming packets into categories, and forwards packets in the same categories to the same NsObject.
The forwarding NsObject is installed in a so-called "slot". Class Classifier defines a link-list variable "slot_" which holds forwarding NsObjects. The NsObject is "i" slot can be obtained by referring to "slot[i]". If no NsObject is placed in slot "i", and you are trying to access "slot_[i]", a "no-slot" error will be shown on the screen.
Example (trying to access slot "-1"):
_o18: no target for slot -1
_o18 type: Classifier/Hash/Dest
content dump:
classifier _o18
0 offset
0 shift
2147483647 mask
1 slots
slot 2: _o116 (Classifier/Port)
-1 default
For more information about Classifiers, see Chapter 6 in the following book from Springer:
T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator NS2", Springer 2008.
http://www.springer.com/engineering/signals/book/978-0-387-71759-3
You may also find the following website useful:
http://www.ece.ubc.ca/~teerawat/NS2.htm
From previous post, a classifier is a multi-target packet forwarder. It classifies incoming packets into categories, and forwards packets in the same categories to the same NsObject.
The forwarding NsObject is installed in a so-called "slot". Class Classifier defines a link-list variable "slot_" which holds forwarding NsObjects. The NsObject is "i" slot can be obtained by referring to "slot[i]". If no NsObject is placed in slot "i", and you are trying to access "slot_[i]", a "no-slot" error will be shown on the screen.
Example (trying to access slot "-1"):
_o18: no target for slot -1
_o18 type: Classifier/Hash/Dest
content dump:
classifier _o18
0 offset
0 shift
2147483647 mask
1 slots
slot 2: _o116 (Classifier/Port)
-1 default
For more information about Classifiers, see Chapter 6 in the following book from Springer:
T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator NS2", Springer 2008.
http://www.springer.com/engineering/signals/book/978-0-387-71759-3
You may also find the following website useful:
http://www.ece.ubc.ca/~teerawat/NS2.htm
Tuesday, March 3, 2009
NS2 Trace Format
When using trace-all in NS2, a trace string is created in a trace file. The format of a trace string is shown below:

where 12 fields of the trace string are as follows.
1. Type Identifier:
3. Source Node and Destination Node: denote the IDs of the source and the destination nodes of the tracing object.
4. Packet Name: Name of the packet type
5. Packet Size: Size of the packet in bytes.
6. Flags: A 7-digit flag string
8-9. Source Address and Destination Address: the format of these two fields is "a.b", where "a" is
10. the address and "b" is the port.
11. Sequence Number
12. Packet Unique ID
For more information about tracing in NS2, see Chapter 13 in the following book from Springer:
T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator NS2", Springer 2008.
http://www.springer.com/engineering/signals/book/978-0-387-71759-3
You may also find the following website useful:
http://www.ece.ubc.ca/~teerawat/NS2.htm
where 12 fields of the trace string are as follows.
1. Type Identifier:
- "+": a packet enque event
- "-": a packet deque event
- "r": a packet reception event
- "d": a packet drop (e.g., sent to dropHead_) event
- "c": a packet collision at the MAC level
3. Source Node and Destination Node: denote the IDs of the source and the destination nodes of the tracing object.
4. Packet Name: Name of the packet type
5. Packet Size: Size of the packet in bytes.
6. Flags: A 7-digit flag string
- "-": disable
- 1st = "E": ECN (Explicit Congestion Notification) echo is enabled.
- 2nd = "P": the priority in the IP header is enabled.
- 3rd : Not in use
- 4th = "A": Congestion action
- 5th = "E": Congestion has occurred.
- 6th = "F": The TCP fast start is used.
- 7th = "N": Explicit Congestion Notification (ECN) is on.
8-9. Source Address and Destination Address: the format of these two fields is "a.b", where "a" is
10. the address and "b" is the port.
11. Sequence Number
12. Packet Unique ID
For more information about tracing in NS2, see Chapter 13 in the following book from Springer:
T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator NS2", Springer 2008.
http://www.springer.com/engineering/signals/book/978-0-387-71759-3
You may also find the following website useful:
http://www.ece.ubc.ca/~teerawat/NS2.htm
Monday, March 2, 2009
Classifiers
A classifier is a multi-target packet forwarder. It classifies incoming packets into categories, and forwards packets in the same categories to the same object.
Main characteristic:
1. Install NsObject in slot_[i] of the classifier
2. Make function classify(p) return the port number of "p"
For more information about Classifiers, see Chapter 6 in the following book from Springer:
T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator NS2", Springer 2008.
http://www.springer.com/engineering/signals/book/978-0-387-71759-3
You may also find the following website useful:
http://www.ece.ubc.ca/~teerawat/NS2.htm
A classifier is a multi-target packet forwarder. It classifies incoming packets into categories, and forwards packets in the same categories to the same object.
Main characteristic:
- A classifier installs the target in its array slot_
- A classifier is an NsObject. Therefore, it receives a packet using its function recv(p,h).
- When receiving a packet p, it looks for a matching slot (i.e., node = find(p)) and forward th packet to the object installed in that slot (i.e., node->recv(p,h))
- Function finds looks for a slot (i.e., cl) with matching criterion, using function classify(p).
- Function classify(p) returns a slot with matching criterion. It is defined in the derived class.
{Example: Suppose we would like to forward packets with port "i" to the same object.
NsObject* node = find(p);
if (node == NULL) {
Packet::free(p);
return;
}
node->recv(p,h);
}
NsObject* Classifier::find(Packet* p)
{
NsObject* node = NULL;
int cl = classify(p);
if (cl <>= nslot_ || (node = slot_[cl]) == 0) {
/*There is no potential target in the slot;*/
}
return (node);
}
1. Install NsObject in slot_[i] of the classifier
2. Make function classify(p) return the port number of "p"
For more information about Classifiers, see Chapter 6 in the following book from Springer:
T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator NS2", Springer 2008.
http://www.springer.com/engineering/signals/book/978-0-387-71759-3
You may also find the following website useful:
http://www.ece.ubc.ca/~teerawat/NS2.htm
Friday, February 27, 2009
Packet size in NS2
In general, a packet consists of packet header and data payload. Packet header stores packet attributes (e.g., source and destination IP addresses) necessary for packet delivery, while data payload contains user information. Although this concept is typical in practice, NS2 models packets differently.
In most cases, NS2 extracts information from data payload and stores the information into packet header. This idea removes the necessity to process data payload at runtime. For example, instead of counting the number of bits in a packet, NS2 stores packet size in variable hdr_cmn::size_, and accesses this variable at runtime
Given a pointer to a Packet object p, the following statement sets the packet size to be "my_size"
For more information about Packets, see Chapter 8 in the following book from Springer:
T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator NS2", Springer 2008.
http://www.springer.com/engineering/signals/book/978-0-387-71759-3
You may also find the following website useful:
http://www.ece.ubc.ca/~teerawat/NS2.htm
In most cases, NS2 extracts information from data payload and stores the information into packet header. This idea removes the necessity to process data payload at runtime. For example, instead of counting the number of bits in a packet, NS2 stores packet size in variable hdr_cmn::size_, and accesses this variable at runtime
Given a pointer to a Packet object p, the following statement sets the packet size to be "my_size"
hdr_cmn* hdr = hdr_cmn::access(p);
hdr->size() = my_size;
For more information about Packets, see Chapter 8 in the following book from Springer:
T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator NS2", Springer 2008.
http://www.springer.com/engineering/signals/book/978-0-387-71759-3
You may also find the following website useful:
http://www.ece.ubc.ca/~teerawat/NS2.htm
Sunday, February 8, 2009
[NS2] The difference between an instproc "compute-routes" and a C++ function "computes_routes()"
Two NS2 functions and instproc has very similar name: "compute-routes{}" and "compute_routes()". The differences are shown below:
compute-routes{}
compute_routes()
For more information about Nodes and Route setup, see Chapter 6 in the following book from Springer:
T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator
NS2", Springer 2008.
http://www.springer.com/engineering/signals/book/978-0-387-71759-3
You may also find the following website useful:
http://www.ece.ubc.ca/~teerawat/NS2.htm
compute-routes{}
- is an OTcl command
- is defined in class Simulator
- is defined in file ~ns/tcl/lib/ns-route.tcl
- populate routing information into nodes
compute_routes()
- is a C++ function
- is defined in class RouteLogic
- is defined in file ~ns/routing/route.cc
- computes the routing information for all pairs of nodes
For more information about Nodes and Route setup, see Chapter 6 in the following book from Springer:
T. Issaraiyakul and E. Hossain, "Introduction to Network Simulator
NS2", Springer 2008.
http://www.springer.com/engineering/signals/book/978-0-387-71759-3
You may also find the following website useful:
http://www.ece.ubc.ca/~teerawat/NS2.htm
Subscribe to:
Comments (Atom)