Exemplo n.º 1
0
void TMIgraph::get_FID2crouter(set<string>& crouters, set<string> &publishers, string &subscriber, map<string, pair<Bitvector, unsigned int> > &allfids, map<string, Bitvector>& p2sfids)
{
    Bitvector tempfid(FID_LEN*8) ;
    unsigned int tempdis = 0 ;
    for(set<string>::iterator iter = crouters.begin() ; iter != crouters.end() ; iter++)
    {
        tempfid.clear() ;
        string router = *iter ;
        calculateFID(subscriber, router, tempfid, tempdis) ;
        allfids[*iter] = make_pair(tempfid, tempdis) ;
        tempfid.clear() ;
        calculateFID(router, subscriber, tempfid, tempdis) ;
        p2sfids[*iter] = tempfid ;
    }
    for(set<string>::iterator iter = publishers.begin() ; iter != publishers.end() ; iter++ )
    {
        tempfid.clear() ;
        string temppub = *iter ;
        calculateFID(subscriber, temppub, tempfid, tempdis) ;
        allfids[*iter] = make_pair(tempfid, tempdis) ;
        tempfid.clear() ;
        calculateFID(temppub, subscriber, tempfid, tempdis) ;
        p2sfids[*iter] = tempfid ;
    }
}
Exemplo n.º 2
0
void GraphRepresentation::calculateTMFIDs() {
    string TMLabel = dm->TM_node->label;
    for (int i = 0; i < dm->network_nodes.size(); i++) {
        NetworkNode *nn = dm->network_nodes[i];
        nn->FID_to_TM = calculateFID(nn->label, TMLabel);
    }
}
Exemplo n.º 3
0
void GraphRepresentation::calculateRVFIDs() {
    string RVLabel = dm->RV_node->label;
    for (int i = 0; i < dm->network_nodes.size(); i++) {
        NetworkNode *nn = dm->network_nodes[i];
        nn->FID_to_RV = calculateFID(nn->label, RVLabel);
    }
}
Exemplo n.º 4
0
//cinc: calculate a multicast path from a single source
void TMIgraph::calculateMulticastFID(string &source, vector<string> &destinations, Bitvector &result)
{
    Bitvector tempresFID(FID_LEN*8) ;

    unsigned int noofhops ;
    for(int i = 0 ; i < destinations.size() ; i++)
    {
        Bitvector tempFID(FID_LEN*8) ;
        calculateFID(source, destinations[i], tempFID, noofhops) ;
        tempresFID = tempresFID | tempFID ;
    }
    result = tempresFID ;
}
Exemplo n.º 5
0
/*main function for rendezvous*/
void TMIgraph::calculateFID(set<string> &publishers, set<string> &subscribers,\
                            map<string, Bitvector *> &result,\
                            map<string,map<string, Bitvector *> > &opresult) {
    set<string>::iterator subscribers_it;
    set<string>::iterator publishers_it;
    string bestPublisher;
    Bitvector resultFID(FID_LEN*8) ;
    Bitvector bestFID(FID_LEN * 8);
    unsigned int numberOfHops = 0;

    //first add all publishers to the hashtable with NULL FID
    for(publishers_it = publishers.begin() ; publishers_it != publishers.end() ; publishers_it++)
    {
        string publ = *publishers_it;
        result.insert(pair<string, Bitvector *>(publ, NULL));
        for(subscribers_it = subscribers.begin() ; subscribers_it != subscribers.end() ; subscribers_it++)
        {
            opresult[*publishers_it][*subscribers_it] = NULL ;
        }
    }
    for(subscribers_it = subscribers.begin() ; subscribers_it != subscribers.end() ; subscribers_it++)
    {
        /*for all subscribers calculate the number of hops from all publishers (not very optimized...don't you think?)*/
        unsigned int minimumNumberOfHops = UINT_MAX;
        for(publishers_it = publishers.begin() ; publishers_it != publishers.end() ; publishers_it++)
        {
            resultFID.clear();
            string str1 = (*publishers_it);
            string str2 = (*subscribers_it);
            calculateFID(str1, str2, resultFID, numberOfHops);

            opresult[*publishers_it][*subscribers_it] = new Bitvector(resultFID) ;

            if (minimumNumberOfHops > numberOfHops) {
                minimumNumberOfHops = numberOfHops;
                bestPublisher = *publishers_it;
                bestFID = resultFID;
            }
        }
        if ((*result.find(bestPublisher)).second == NULL) {
            //add the publisher to the result
            //cout << "FID1: " << bestFID.to_string() << endl;
            result[bestPublisher] = new Bitvector(bestFID);
        } else {
            //cout << "/*update the FID for the publisher" << endl;
            Bitvector *existingFID = (*result.find(bestPublisher)).second;
            /*or the result FID*/
            *existingFID = *existingFID | bestFID;
        }
    }
}