next up previous
Next: Generation Functionality Up: Extending BRITE's C++ Version Previous: Extending BRITE's C++ Version

Passing parameters to the new Model

Passing of parameters is done in BRITE via a configuration file. This file must be parsed and its contents must be put in a parameter data structure associated with the specific model we are implementing. BRITE provides a base class called ModelPar which is the base class for parameter classes for the models provided with BRITE.

For example, listing 1 shows a C++ excerpt containing the declaration of the RouterWaxPar class which is the parameter class associated to the Router Waxman model. This class contains data members for all parameters required by the Router Waxman model.


\begin{Program}
% latex2html id marker 585\footnotesize\begin{verbatim}class...
...nd{verbatim}\caption{Class associated to router-level Waxman Model}\end{Program}

There is a single entry point to the parsing of configuration files, which is the method:

    ModelPar* Parse::ParseConfigFile();

The method ParseConfigFile, which is invoked from BRITE's main routine, will determine the type of model that must be parsed and then it will invoke the specific method in charge of parsing parameters for the corresponding model. As an example, let's suppose that ParseConfigFile is parsing a configuration file for generating a Waxman topology. Listing 6.1.1 shows such a configuration file.


\begin{Listing}
\footnotesize\begin{verbatim}BriteConfigBeginModel
Name = 1...
...HT = 3, Exp =4
BWMin = 10.0
BWMax = 1024.0
EndModel\end{verbatim}\end{Listing}

Upon parsing the field Name = 1, ParseConfigFile will determine that it must parse parameters for the RouterWaxman model and will invoke the appropriate parsing procedure, ParseRouterWaxman in this case. Excerpt 2 shows this logic.


\begin{Program}
% latex2html id marker 606\footnotesize\begin{verbatim}...
...
...batim}\caption{Parsing logic for a RouterWaxman configuration file}\end{Program}

ParseRouterWaxman, shown in code excerpt 3, will parse the parameters associated with the Waxman model.


\begin{Program}
% latex2html id marker 614\footnotesize\begin{verbatim}Route...
...r;
}\end{verbatim}\caption{Parsing routine for Router Waxman model}\end{Program}

At this point, ParseConfigFile returns to BRITE's main routine the data structure with the parameters just parsed. Next, BRITE instantiates an object of the model class we are creating, and uses it to create the corresponding topology. Code excerpt 4 shows the logic for the last step.


\begin{Program}
% latex2html id marker 622\footnotesize\begin{verbatim}...
...
.....
}\end{verbatim}\caption{Parsing routine for Router Waxman model}\end{Program}

In summary with respect to parameter passing, when we are adding a new model we must create a parameter class, NewModelPar, which will contain the parameters for the new model. In addition, we must provide parsing procedure such as ParseRouterWaxman for our new model. Finally, we have to modify the following parts of the code:

  1. Add a new model id to the enum type ModelType in Model.h
  2. Add the code for the new parsing routine in Parser.cc
  3. Modify ParseConfigFile in Parser.cc to check for the new model type and invoke the new parsing routine.
  4. Modify BRITE's main routine in BriteMain.cc to check for the type of the new model and invoke the constructor for the new model class.


next up previous
Next: Generation Functionality Up: Extending BRITE's C++ Version Previous: Extending BRITE's C++ Version
Alberto Medina 2001-04-12