Friday, March 13, 2009

[NS2] Dropping a Packet

Suppose you have a pointer "p". You can drop the packet by executing

Packet::free(p)
Also the packet "*p" can be dropped from within the Connector object by invoking function drop as follows:
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

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:
  • "+": 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
2. Time: at which the packet tracing string is created.
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.
7. Flow ID
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:
  • 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.
void Classifier::recv(Packet* p, Handler* h)
{
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);
}
Example: Suppose we would like to forward packets with port "i" to the same object.
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