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