Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members  

Functions


Finding global objects by name.

cNetworkTypefindNetwork (const char *s)
cModuleTypefindModuleType (const char *s)
cModuleInterfacefindModuleInterface (const char *s)
cLinkTypefindLink (const char *s)
cFunctionTypefindFunction (const char *s)
cInspectorFactoryfindInspectorFactory (const char *s)
cEnumfindEnum (const char *s)

Connecting gates.

SIM_API void connect (cModule *frm, int frg, cLinkType *linkp, cModule *tom, int tog)
SIM_API void connect (cModule *frm, int frg, cPar *delayp, cPar *errorp, cPar *dataratep, cModule *tom, int tog)

Miscellaneous functions.

SIM_API void* createOne (const char *classname)

Converting simulation time to and from string form.

SIM_API simtime_t strToSimtime (const char *str)
SIM_API simtime_t strToSimtime0 (const char *&str)
SIM_API char* simtimeToStr (simtime_t t, char *dest=NULL)

Random number generation.

OMNeT++ has a built-in pseudo random number generator that gives long int (32-bit) values in the range 1...2^31-2, with a period length of 2^31-2.

The generator is a linear congruential generator (LCG), and uses the method x=(x * 75) mod (2^31-1). The testrand() method can be used to check if the generator works correctly. Required hardware is exactly 32-bit integer arithmetics.

OMNeT++ provides several independent random number generators (by default 32; this number is defined as NUM_RANDOM_GENERATORS in utils.h), identified by numbers. The generator number is usually the gen_nr argument to functions beginning with genk_.

Source: Raj Jain: The Art of Computer Systems Performance Analysis (John Wiley & Sons, 1991), pages 441-444, 455.

SIM_API int testrand ()
SIM_API long opp_nextrand (long &seed)
SIM_API void opp_randomize ()
SIM_API long randseed ()
SIM_API long randseed (long seed)
SIM_API long intrand ()
SIM_API long intrand (long r)
double dblrand ()
SIM_API void genk_opp_randomize (int gen_nr)
SIM_API long genk_randseed (int gen_nr)
SIM_API long genk_randseed (int gen_nr, long seed)
SIM_API long genk_intrand (int gen_nr)
SIM_API long genk_intrand (int gen_nr, long r)
double genk_dblrand (int gen_nr)

Distributions.

Argument types and return value must be `double' so that they can be used in NED files, and cPar 'F' and 'X' types.

SIM_API double uniform (double a, double b)
SIM_API double intuniform (double a, double b)
SIM_API double exponential (double mean)
SIM_API double normal (double mean, double variance)
SIM_API double truncnormal (double mean, double varianced)
SIM_API double genk_uniform (double gen_nr, double a, double b)
SIM_API double genk_intuniform (double gen_nr, double a, double b)
SIM_API double genk_exponential (double gen_nr, double p)
SIM_API double genk_normal (double gen_nr, double mean, double variance)
SIM_API double genk_truncnormal (double gen_nr, double mean, double variance)

Utility functions to support nedc-compiled expressions.

SIM_API double min (double a, double b)
SIM_API double max (double a, double b)
SIM_API double bool_and (double a, double b)
SIM_API double bool_or (double a, double b)
SIM_API double bool_xor (double a, double b)
SIM_API double bool_not (double a)
SIM_API double bin_and (double a, double b)
SIM_API double bin_or (double a, double b)
SIM_API double bin_xor (double a, double b)
SIM_API double bin_compl (double a)
SIM_API double shift_left (double a, double b)
SIM_API double shift_right (double a, double b)

String-related utility functions.

Some of these functions are similar to <string.h> functions, with the exception that they also accept NULL pointers as empty strings (""), and use operator new instead of malloc(). It is recommended to use these functions instead of the original <string.h> functions.

SIM_API char* opp_strdup (const char *)
SIM_API char* opp_strcpy (char *,const char *)
SIM_API int opp_strcmp (const char *, const char *)
SIM_API bool opp_strmatch (const char *, const char *)
SIM_API int opp_strlen (const char *)
SIM_API char* opp_mkindexedname (char *dest, const char *name, int index)
SIM_API char* opp_concat (const char *s1, const char *s2, const char *s3=NULL, const char *s4=NULL)
SIM_API char* opp_strprettytrunc (char *dest, const char *src, unsigned maxlen)
const char* correct (const char *)

Miscellaneous functions.

bool equal (double a, double b, double epsilon)

Function Documentation

SIM_API double bin_and ( double a,
double b )
 

Returns the binary AND of a and b. (a and b are converted to unsigned long for the operation.)

SIM_API double bin_compl ( double a )
 

Returns the bitwise negation (unary complement) of a. (a is converted to unsigned long for the operation.)

SIM_API double bin_or ( double a,
double b )
 

Returns the binary OR of a and b. (a and b are converted to unsigned long for the operation.)

SIM_API double bin_xor ( double a,
double b )
 

Returns the binary exclusive OR of a and b. (a and b are converted to unsigned long for the operation.)

SIM_API double bool_and ( double a,
double b )
 

Returns the boolean AND of a and b. (Any nonzero number is treated as true.)

SIM_API double bool_not ( double a )
 

Returns the boolean negation of a. (Any nonzero number is treated as true.)

SIM_API double bool_or ( double a,
double b )
 

Returns the boolean OR of a and b. (Any nonzero number is treated as true.)

SIM_API double bool_xor ( double a,
double b )
 

Returns the boolean Exclusive OR of a and b. (Any nonzero number is treated as true.)

SIM_API void connect ( cModule * frm,
int frg,
cPar * delayp,
cPar * errorp,
cPar * dataratep,
cModule * tom,
int tog )
 

Connects two gates.

SIM_API void connect ( cModule * frm,
int frg,
cLinkType * linkp,
cModule * tom,
int tog )
 

Connects two gates.

const char * correct ( const char * s ) [inline]
 

Returns the pointer passed as argument unchanged, except that if it was NULL, it returns a pointer to a null string ("").

SIM_API void * createOne ( const char * classname )
 

Creates an instance of a particular class; the result has to be cast to the appropriate type by hand. The class must have been registered previously with the Register_Class() macro. This function internally relies on the cClassRegister class.

See also:
Register_Class() macro , cClassRegister class

double dblrand ( ) [inline]
 

Produces random double in range 0.0...1.0 using generator 0.

bool equal ( double a,
double b,
double epsilon ) [inline]
 

Tests equality of two doubles, with the given precision.

SIM_API double exponential ( double mean )
 

Returns a random number with exponential distribution with the given mean (with parameter 1/mean). Uses generator 0.

cEnum * findEnum ( const char * s ) [inline]
 

Find a cEnum.

cFunctionType * findFunction ( const char * s ) [inline]
 

Find a cFunctionType.

cInspectorFactory * findInspectorFactory ( const char * s ) [inline]
 

Find a cInspectorFactory.

cLinkType * findLink ( const char * s ) [inline]
 

Find a cLinkType.

cModuleInterface * findModuleInterface ( const char * s ) [inline]
 

Find a cModuleInterface.

cModuleType * findModuleType ( const char * s ) [inline]
 

Find a cModuleType.

cNetworkType * findNetwork ( const char * s ) [inline]
 

Find a cNetworkType.

double genk_dblrand ( int gen_nr ) [inline]
 

Produces random double in range 0.0...1.0 using generator gen_nr.

SIM_API double genk_exponential ( double gen_nr,
double p )
 

Same as exponential(), only uses random generator gen_nr instead of generator 0.

SIM_API long genk_intrand ( int gen_nr,
long r )
 

Produces random integer in range 0...r-1 using generator gen_nr. (Assumes r << INTRAND_MAX.)

SIM_API long genk_intrand ( int gen_nr )
 

Produces random integer in the range 1...INTRAND_MAX using generator gen_nr.

SIM_API double genk_intuniform ( double gen_nr,
double a,
double b )
 

Same as intuniform(), only uses random generator gen_nr instead of generator 0.

SIM_API double genk_normal ( double gen_nr,
double mean,
double variance )
 

Same as normal(), only uses random generator gen_nr instead of generator 0.

SIM_API void genk_opp_randomize ( int gen_nr )
 

Initialize random number generator gen_nr with a random value.

SIM_API long genk_randseed ( int gen_nr,
long seed )
 

Sets seed of generator gen_nr and returns old seed value. Zero is not allowed as a seed.

SIM_API long genk_randseed ( int gen_nr )
 

Returns current seed of generator gen_nr.

SIM_API double genk_truncnormal ( double gen_nr,
double mean,
double variance )
 

Same as truncnormal(), only uses random generator gen_nr instead of generator 0.

SIM_API double genk_uniform ( double gen_nr,
double a,
double b )
 

Same as uniform(), only uses random generator gen_nr instead of generator 0.

SIM_API long intrand ( long r )
 

Produces random integer in range 0...r-1 using generator 0. (Assumes r << INTRAND_MAX.)

SIM_API long intrand ( )
 

Produces random integer in the range 1...INTRAND_MAX using generator 0.

SIM_API double intuniform ( double a,
double b )
 

Returns a random integer with uniform distribution in the range [a,b], inclusive. (Note that the function can also return b!) Uses generator 0.

SIM_API double max ( double a,
double b )
 

Returns the maximum of a and b.

SIM_API double min ( double a,
double b )
 

Returns the minimum of a and b.

SIM_API double normal ( double mean,
double variance )
 

Returns a random number with normal distribution with the given mean and variance. Uses generator 0.

SIM_API char * opp_concat ( const char * s1,
const char * s2,
const char * s3 = NULL,
const char * s4 = NULL )
 

Concatenates up to four strings. Returns a pointer to a static buffer of length 256. If the result length would exceed 256, it is truncated.

SIM_API char * opp_mkindexedname ( char * dest,
const char * name,
int index )
 

Creates a string like "component[35]" into dest, the first argument.

SIM_API long opp_nextrand ( long & seed )
 

Calculates the next random number with the given seed, and also updates the seed. This function makes it possible to use random number streams independent of the seeds built into OMNeT++.

SIM_API void opp_randomize ( )
 

Initialize random number generator 0 with a random value.

SIM_API int opp_strcmp ( const char *,
const char * )
 

Same as the standard strcmp() function, except that NULL pointers are treated like pointers to a null string ("").

SIM_API char * opp_strcpy ( char *,
const char * )
 

Same as the standard strcpy() function, except that NULL pointers in the second argument are treated like pointers to a null string ("").

SIM_API char * opp_strdup ( const char * )
 

Duplicates the string. If the pointer passed is NULL or points to a null string (""), NULL is returned.

SIM_API int opp_strlen ( const char * )
 

Same as the standard strlen() function, except that does not crash on NULL pointers but returns 0.

SIM_API bool opp_strmatch ( const char *,
const char * )
 

Returns true if the two strings are identical up to the length of the shorter one. NULL pointers are treated like pointers to a null string ("").

SIM_API char * opp_strprettytrunc ( char * dest,
const char * src,
unsigned maxlen )
 

Copies src string into desc, and if its length would exceed maxlen, it is truncated with an ellipsis. For example, opp_strprettytrunc(buf, "long-long",6) yields "lon...".

SIM_API long randseed ( long seed )
 

Sets seed of generator 0 and returns old seed value. Zero is not allowed as a seed.

SIM_API long randseed ( )
 

Returns current seed of generator 0.

SIM_API double shift_left ( double a,
double b )
 

Shifts a b bits to the left. (a and b are converted to unsigned long for the operation.)

SIM_API double shift_right ( double a,
double b )
 

Shifts a b bits to the right. (a and b are converted to unsigned long for the operation.)

SIM_API char * simtimeToStr ( simtime_t t,
char * dest = NULL )
 

Converts simulation time (passed as simtime_t) into a string like "0.0120000 (12ms)". If no destination pointer is given, uses a static buffer.

SIM_API simtime_t strToSimtime ( const char * str )
 

Convert a string to simtime_t. The string should have a format similar to the one output by simtimeToStr() (like "1s 34ms").

Returns -1 if the whole string cannot be interpreted as time. Empty string (or only spaces+tabs) is also an error. E.g. strtoSimtime("3s 600ms x") will return -1.

SIM_API simtime_t strToSimtime0 ( const char *& str )
 

Convert the beginning of a string to simtime_t. Similar to strToSimtime(), only it processes the string as far as it can be interpreted as simulation time. It sets the pointer passed to the first character which cannot be interpreted as part of the time string, or to the terminating zero. Empty string is accepted as 0.0. E.g. strToSimtime0("3s 600ms x") will return 3.6 and the pointerstr will point to the character 'x'.

SIM_API int testrand ( )
 

Returns 1 if the random generator works OK. Keeps seed intact. It works by checking the following: starting with x[0]=1, x[10000]=1,043,618,065 must hold.

SIM_API double truncnormal ( double mean,
double varianced )
 

Normal distribution truncated to nonnegative values. Note that because it is implemented with a loop that discards negative values until a nonnegative comes, the execution time is not bounded (a large negative mean with much smaller variance may result in many iterations and very long execution time). Uses generator 0.

SIM_API double uniform ( double a,
double b )
 

Returns a random number with uniform distribution in the range [a,b). Uses generator 0.


Generated at Sat May 4 15:45:52 2002 for OMNeT++ by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001