CDtnRequestManager::CDtnRequestManager(Node* node, int interfaceIndex, const NodeInput* nodeInput):m_node(node)
{
    //initialize seed
    RANDOM_SetSeed(m_seed,node->globalSeed,node->nodeId,ROUTING_PROTOCOL_ICAN, interfaceIndex);    

    m_pRequestStore = new BloomFilterStore;
}
예제 #2
0
// Copyright (c) 2001-2013, SCALABLE Network Technologies, Inc.  All Rights Reserved.
//                          600 Corporate Pointe
//                          Suite 1200
//                          Culver City, CA 90230
//                          [email protected]
//
// This source code is licensed, not sold, and is subject to a written
// license agreement.  Among other things, no portion of this source
// code may be copied, transmitted, disclosed, displayed, distributed,
// translated, used as the basis for a derivative work, or used, in
// whole or in part, for any program or purpose other than its intended
// use in compliance with the license agreement as part of the QualNet
// software.  This source code and certain of the algorithms contained
// within it are confidential trade secrets of Scalable Network
// Technologies, Inc. and may not be used as the basis for any other
// software, hardware, product or service.

#include "layer2_lte_sch_roundrobin.h"
#ifdef LTE_LIB_LOG
#include "log_lte.h"
#endif

#define EFFECTIVE_SINR_BY_AVERAGE 1
#define LTE_BER_BASED 1

// /**
// FUNCTION   :: LteSchedulerENBRoundRobin::LteSchedulerENBRoundRobin
// LAYER      :: MAC
// PURPOSE    :: Initialize Round Robin scheduler
// PARAMETERS ::
// + node           : Node* : Node Pointer
// + interfaceIndex : int   : Interface index
// + nodeInput      : const NodeInput* : Pointer to node input
// RETURN::    void:         NULL
// **/
LteSchedulerENBRoundRobin::LteSchedulerENBRoundRobin(
    Node* node, int interfaceIndex, const NodeInput* nodeInput)
    : LteSchedulerENB(node, interfaceIndex, nodeInput)
{
#if SCH_LTE_ENABLE_RR_RANDOM_SORT
    RANDOM_SetSeed(
            randomSeed,
            node->globalSeed,
            node->nodeId,
            MAC_PROTOCOL_LTE,
            interfaceIndex);
#endif

    _dlNextAllocatedUe = _dlConnectedUeList.end();
    _ulNextAllocatedUe = _ulConnectedUeList.end();
}
예제 #3
0
파일: mac_aloha.cpp 프로젝트: LXiong/ccn
void
AlohaInit(Node* node, int interfaceIndex, const NodeInput* nodeInput, const int nodesInSubnet) {

    AlohaData *dataPtr = NULL;
    Message *msg = NULL;

    //UserCodeStartInit
    dataPtr = (AlohaData *) MEM_malloc(sizeof(AlohaData));

    assert(dataPtr != NULL);

    memset(dataPtr, 0, sizeof(AlohaData));
    dataPtr->myMacData = node->macData[interfaceIndex];
    dataPtr->myMacData->macVar = (void *)dataPtr;
    dataPtr->initStats = TRUE;
    dataPtr->mode = ALOHA_IDLE;
    dataPtr->txMode = ALOHA_TX_IDLE;

    memset(&dataPtr->ACKAddress, 255, sizeof(Mac802Address));
    dataPtr->numTimeouts = 0;
    dataPtr->currentFrame = NULL;
    dataPtr->retransmitTimer = NULL;
    dataPtr->stats.pktsDropped = 0;

    RANDOM_SetSeed(dataPtr->seed,
                   node->globalSeed,
                   node->nodeId,
                   MAC_PROTOCOL_ALOHA,
                   interfaceIndex);

    //UserCodeEndInit
    if (dataPtr->initStats) {
        AlohaInitStats(node, &(dataPtr->stats));
    }
    dataPtr->state = ALOHA_IDLE_STATE;
    enterAlohaIdleState(node, dataPtr, msg);

#ifdef PARALLEL //Parallel
    PARALLEL_SetProtocolIsNotEOTCapable(node);
    PARALLEL_SetMinimumLookaheadForInterface(node, 0);
#endif //endParallel
}
예제 #4
0
파일: s_random.c 프로젝트: aharrison24/HAL
/**
 * Initialize random number generator context.
 */
STATIC Bool RANDOM_Init(Random * r, const RNG * algorithm)
{
    const RNG * rng = (algorithm ? algorithm : (&RNG_Lehmer));
    ASSERT(rng->rng_next);
    ASSERT(rng->rng_seed);
    if (MUTEX_Init(&r->mutex)) {
        void * ctx = NULL;
        if (!rng->rng_init || (ctx = (*(rng->rng_init))(r)) != NULL) {
#ifndef __KERNEL__
            r->nextGaussian = 0;
            r->haveNextGaussian = False;
#endif /* __KERNEL__ */
            r->rng = (*rng);
            r->ctx = ctx;
            r->syn = True;     /* synchronize by default */
            RANDOM_SetSeed(r, RANDOM_GenSeed());
            return True;
        }
        MUTEX_Destroy(&r->mutex);
    }
    return False;
}
CDtnCacheSummaryStore::CDtnCacheSummaryStore(Node* node, const NodeInput* nodeInput, int interfaceIndex):m_node(node)
{

    //initialize seed
    RANDOM_SetSeed(m_seed,node->globalSeed,node->nodeId,ROUTING_PROTOCOL_ICAN, interfaceIndex);

    //initiate bloomfilter parameters
    BOOL retVal;
    //read expected number of item
    int nItem;
    IO_ReadInt(
        node->nodeId,
        ANY_ADDRESS,
        nodeInput,
        "BF-NUMITEM",
        &retVal,
        &nItem);
    if (retVal == FALSE || nItem < 0)
    {
        char errorString[MAX_STRING_LENGTH];
        sprintf(errorString,
                "Wrong BF-NUMITEM configuration format!\n"
               );
        ERROR_ReportError(errorString);
    }
    //read expected false postive rate
    double fpRate;
    IO_ReadDouble(
        node->nodeId,
        ANY_ADDRESS,
        nodeInput,
        "BF-FPRATE",
        &retVal,
        &fpRate);
    if (retVal == FALSE || nItem < 0)
    {
        char errorString[MAX_STRING_LENGTH];
        sprintf(errorString,
                "Wrong BF-FPRATE configuration format!\n"
               );
        ERROR_ReportError(errorString);
    }
    //read salt seed
    int seed;
    IO_ReadInt(
        node->nodeId,
        ANY_ADDRESS,
        nodeInput,
        "BF-SALT",
        &retVal,
        &seed);
    if (retVal == FALSE || nItem < 0)
    {
        char errorString[MAX_STRING_LENGTH];
        sprintf(errorString,
                "Wrong BF-SALT configuration format!\n"
               );
        ERROR_ReportError(errorString);
    }

    //calculate BF parameters
    bfparameters.projected_element_count    = nItem;
    bfparameters.false_positive_probability = fpRate;
    bfparameters.random_seed                = seed;
    bfparameters.compute_optimal_parameters();


    m_pCacheSummaries = new BloomFilterStore;

}
예제 #6
0
파일: phy_cellular.cpp 프로젝트: LXiong/ccn
// software.  This source code and certain of the algorithms contained
// within it are confidential trade secrets of Scalable Network
// Technologies, Inc. and may not be used as the basis for any other
// software, hardware, product or service.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#include "api.h"
#include "antenna.h"
#include "antenna_switched.h"
#include "antenna_steerable.h"

#include "cellular.h"
#include "phy_cellular.h"

#ifdef UMTS_LIB
#include "cellular_umts.h"
#include "phy_umts.h"
#endif

#ifdef MUOS_LIB
#include "cellular_muos.h"
#include "phy_muos.h"
#endif

#define DEBUG 0
// /**
// FUNCTION   :: PhyCellularInit
// LAYER      :: PHY
// PURPOSE    :: Initialize the Cellular PHY
// PARAMETERS ::
// + node      : Node*            : Pointer to node.
// + phyIndex  : const int        : Index of the PHY
// + nodeInput : const NodeInput* : Pointer to the node input
// RETURN     :: void             : NULL
// **/
void PhyCellularInit(Node *node,
                  const int phyIndex,
                  const NodeInput *nodeInput)
{
    Address interfaceAddress;
    char buf[MAX_STRING_LENGTH];
    BOOL retVal;

    PhyCellularData *phyCellular =
        (PhyCellularData*) MEM_malloc(sizeof(PhyCellularData));

    phyCellular->thisPhy = node->phyData[phyIndex];
    node->phyData[phyIndex]->phyVar = ( void* )phyCellular;

    // generate initial seed
    RANDOM_SetSeed(phyCellular->randSeed,
                   node->globalSeed,
                   node->nodeId,
                   PHY_CELLULAR,
                   phyIndex);

    if (DEBUG)
    {
        printf("node %d: Cellular Phy Init\n", node->nodeId);
    }

    NetworkGetInterfaceInfo(node,
                            phyCellular->thisPhy->macInterfaceIndex,
                            &interfaceAddress);
    IO_ReadString(
        node,
        node->nodeId,
        phyCellular->thisPhy->macInterfaceIndex,
        nodeInput,
        "CELLULAR-PHY-MODEL",
        &retVal,
        buf);
    if (retVal == FALSE)
    {
        ERROR_ReportError("CELLULAR-PHY-MODEL parameter"
            " was not found for node");
    }

    if (strcmp(buf, "PHY-ABSTRACT-CELLULAR") == 0)
    {
        if (DEBUG)
        {
            printf("node %d: Calling Abstract Cellular Phy Init\n",
                node->nodeId);
        }
        phyCellular->cellularPhyProtocolType =
            Cellular_ABSTRACT_Phy;

    }
    else if (strcmp(buf, "PHY-GSM") == 0)
    {
        if (DEBUG)
        {
            printf("node %d: GSM Cellular Phy init\n",node->nodeId);
        }
        phyCellular->cellularPhyProtocolType =
            Cellular_GSM_Phy;
    }
    else if (strcmp(buf, "PHY-GPRS") == 0)
    {
        if (DEBUG)
        {
            printf("node %d: GPRS Cellular Phy init\n",node->nodeId);
        }
        phyCellular->cellularPhyProtocolType =
            Cellular_GPRS_Phy;
    }
    else if (strcmp(buf, "PHY-UMTS") == 0)
    {
#if defined(UMTS_LIB)
        phyCellular->cellularPhyProtocolType = Cellular_UMTS_Phy;
        PhyUmtsInit(node, phyIndex, nodeInput);
#else
        ERROR_ReportMissingLibrary("PHY-UMTS", "UMTS");
#endif
    }
    else if (strcmp(buf, "PHY-MUOS") == 0)
    {
#if defined(MUOS_LIB)
        phyCellular->cellularPhyProtocolType = Cellular_MUOS_Phy;
        PhyMuosInit(node, phyIndex, nodeInput);
#else
        ERROR_ReportMissingLibrary("PHY-MUOS", "MUOS");
#endif
    }
    else if (strcmp(buf, "PHY-CDMA2000") == 0)
    {
        if (DEBUG)
        {
            printf("node %d: CDMA2000 Cellular PHY init\n",node->nodeId);
        }
        phyCellular->cellularPhyProtocolType =
            Cellular_CDMA2000_Phy;
    }
    else if (strcmp(buf, "PHY-WIMAX") == 0)
    {
        if (DEBUG)
        {
            printf("node %d: WIMAX Cellular PHY init\n",node->nodeId);
        }
        phyCellular->cellularPhyProtocolType =
            Cellular_WIMAX_Phy;
    }
    else
    {
        ERROR_ReportError(
            "CELLULAR-PHY-MODEL parameter must be ABSTRACT-CELLULAR-PHY,"
            " PHY-GSM, PHY-GPRS, PHY-UMTS, PHY-CDMA2000"
            " or PHY-WIMAX");
    }

    IO_ReadString(
                node->nodeId,
                ANY_DEST,
                nodeInput,
                "CELLULAR-STATISTICS",
                &retVal,
                buf);

    if ((retVal == FALSE) || (strcmp(buf, "YES") == 0))
    {
        phyCellular->collectStatistics = TRUE;
    }
    else if (retVal && strcmp(buf, "NO") == 0)
    {
        phyCellular->collectStatistics = FALSE;
    }
    else
    {
        ERROR_ReportWarning(
            "Value of CELLULAR-STATISTICS should be YES or NO! "
            "Default value YES is used.");
        phyCellular->collectStatistics = TRUE;
    }
}
예제 #7
0
//-------------------------------------------------------------------------
// FUNCTION     : NdpInit()
//
// PURPOSE      : Initializing NDP protocol.
//
// PARAMETERS   : node - Node which is initializing NDP
//                ndpData - Pointer to NdpData pointer
//                nodeInput - Node input
//                interfaceIndex - Interface index
//
// ASSUMPTION   : This function will be called from iarp.c.
//-------------------------------------------------------------------------
void NdpInit(
    Node* node,
    void** ndpData,
    const NodeInput* nodeInput,
    int interfaceIndex)
{
    NdpData* myNdp = NULL;
    BOOL retVal = FALSE;
    char buf[MAX_STRING_LENGTH] = {0};

    *ndpData =  MEM_malloc(sizeof(NdpData));
    memset(*ndpData, 0, sizeof(NdpData));

    myNdp = (NdpData*) *ndpData;
    NdpInitNeighborCahce(&(myNdp->ndpNeighborTable));
    myNdp->ndpPeriodicHelloTimer = NDP_PERIODIC_HELLO_TIMER;
    myNdp->numHelloLossAllowed = NDP_NUM_HELLO_LOSS_ALLOWED;

    RANDOM_SetSeed(myNdp->seed,
                   node->globalSeed,
                   node->nodeId,
                   NETWORK_PROTOCOL_NDP,
                   interfaceIndex);

    NdpStatInit(&(myNdp->stats));

    if (nodeInput != NULL)
    {
        // Read statistics collection option from configuration file.
        IO_ReadString(node->nodeId, ANY_DEST, nodeInput,
             "NDP-STATISTICS", &retVal, buf);
    }

    if ((retVal == TRUE) && (strcmp(buf, "YES") == 0))
    {
        myNdp->collectStats = TRUE;
    }
    else
    {
        myNdp->collectStats = FALSE;

    }

    if (NDP_DEBUG)
    {
        // DEBUG statement: Print nodeId of the node
        //                  that is initializing.
        printf("NDP protocol is Initializing in Node : %u\n",
            node->nodeId);
    }

    // Initialize update function pointer (linked) list.
    memset(&(myNdp->updateFuncHandlerList), 0,
        sizeof(NdpUpdateFuncHandlarList));

    // Start Sending hello messages immediately
    NdpScheduleHelloTimer(node, PROCESS_IMMEDIATELY);

    // This statements are for debugging of NDP.
    if (DEBUG_NDP_TEST_NDP_NEIGHBOR_TABLE)
    {
        int i = 0;

        for (i = 1; i <= MUM_OF_TIMER_FIRED; i++)
        {
            Message *dbg = MESSAGE_Alloc(node,
                                         NETWORK_LAYER,
                                         NETWORK_PROTOCOL_NDP,
                                         MSG_NETWORK_PrintRoutingTable);

            MESSAGE_Send(node, dbg, (i * DEBUG_DELAY));
        }
    }
}