QualNet常用函数

1. mapping.h中关于节点指针、节点ID、节点接口地址的转换。每个节点有一个指针、一个ID,多个接口索引及多个接口地址。

1.1 已知节点指针和节点接口地址,获取节点ID

NodeAddress
MAPPING_GetNodeIdFromInterfaceAddress(
    Node *node,
    NodeAddress interfaceAddress);

NodeAddress
MAPPING_GetNodeIdFromInterfaceAddress(
    Node *node,
    Address interfaceAddress);

1.2 已知节点指针和节点ID,获取默认接口地址

NodeAddress
MAPPING_GetDefaultInterfaceAddressFromNodeId(
    Node *node,
    NodeAddress nodeId);

1.3 已知节点指针和节点接口地址,获取节点接口索引 

int
MAPPING_GetInterfaceIndexFromInterfaceAddress(
    Node *node,
    NodeAddress interfaceAddress);

1.4 已知节点ID,获取节点指针(需要用到节点指针与ID的哈希表)

Node*
MAPPING_GetNodePtrFromHash(
    IdToNodePtrMap* hash,
    NodeAddress     nodeId);

2.fileio.h从配置文件中读取数据,初始化参数。常见于初始化阶段协议栈初始化。

void
IO_ReadBool(
    const NodeId nodeId,
    const Address* address,
    const NodeInput *nodeInput,
    const char *parameterName,
    BOOL *wasFound,
    BOOL *parameterValue);

void
IO_ReadString(
    const NodeAddress nodeId,
    const Address* address,
    const NodeInput *nodeInput,
    const char *index,
    BOOL *wasFound,
    char *readVal);

void
IO_ReadInt(
    const NodeId nodeId,
    const Address* address,
    const NodeInput *nodeInput,
    const char *parameterName,
    BOOL* wasFound,
    int *parameterValue);

void
IO_ReadDouble(
    const NodeId nodeId,
    const Address* address,
    const NodeInput *nodeInput,
    const char *parameterName,
    BOOL *wasFound,
    double *parameterValue);

void
IO_ReadInt64(
    const NodeId nodeId,
    const Address* address,
    const NodeInput *nodeInput,
    const char *parameterName,
    BOOL *wasFound,
    Int64 *parameterValue);

void
IO_ReadFloat(
    const NodeId nodeId,
    const Address* address,
    const NodeInput *nodeInput,
    const char *index,
    BOOL *wasFound,
    float *readVal);

void
IO_ReadTime(
    const NodeAddress nodeId,
    const Address* address,
    const NodeInput *nodeInput,
    const char *parameterName,
    BOOL *wasFound,
    clocktype *parameterValue);

3.random.h随机数产生

//产生随机种子,存入seed变量
void RANDOM_SetSeed(RandomSeed seed,
                    UInt32 globalSeed,
                    UInt32 nodeId = 0,
                    UInt32 protocolId = 0,
                    UInt32 instanceId = 0);

//由随机种子产生随机小数,介于0-1之间
extern double RANDOM_erand(RandomSeed);

//由随机种子产生随机整数,介于2的-31次方至2的+31次方
extern Int32  RANDOM_jrand(RandomSeed);

//由随机种子产生随机整数,介于0至2的+31次方
extern Int32  RANDOM_nrand(RandomSeed);

猜你喜欢

转载自blog.csdn.net/zhang1806618/article/details/109245613