Thursday, July 9, 2009

[AIT09] Addressing in NS2

This question is from our friend Hasanain.

The question is
  1. What is the address format in NS2?
  2. Where do we store (IP) address?
  3. How do we store the IP address? (using what function or instproc?)
Any comments?

Wednesday, July 8, 2009

[AIT09] A Welcome Message

Welcome, everyone. As we'll be discuss in the class, this would be the place where we discuss about NS2 course. The purpose is to have you all participate in a meaningful way. Here is how it works.

  1. You send me an email stating problems or questions you have.
  2. I select questions and post the selected questions (with title beginning with [AIT09] and label AIT09) on the blog. The selected question would earn marks.
  3. You help each other by trying to commenting or answering the question. Each thoughtful comment and answer earns marks. The meaningless comments such as "I think so" do not earn marks.

Try to come back here as often as you can. You know, it is easier to comment if you read the discussion first.

Good Luck... Teerawat

Wednesday, April 29, 2009

How an application sends a message to an agent

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

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