亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? main.c

?? PB 熟悉的哥們希望大家可以互相學(xué)習(xí)一下
?? C
字號:
/***************************************************************
 *                                                             *
 * Copyright (c) 2001-2007 McObject LLC. All Right Reserved.   *
 *                                                             *
 ***************************************************************/

/* 
 * This sample demonstrate the use of eXtremeDB for the Routing Table Management software.
 * The program measures the performance for routing table inserts and lookups. The program
 * randomly generates IP addresses, each masked with three masks - 255.255.0.0, 255.255.255.0
 * or 255.255.255.255. We then insert these routes into the routing table, creating a
 * hash-based index based on the {mask/ip address} pair. The database engine filters out
 * duplicate pairs of {mask/ip address} as the new routes are installed into the routing table.
 * After the table is populated, the program searches for a route for a random packet.
 * The algorithm is a combination of a linear search and a tree search, masking the address with
 * each of the three possible masks and then using the index to locate the route. Therefore each
 * address is searched up to three times to find the best match. If more than one route exists,
 * the one with the longest matching prefix is chosen.
 *
 * A somewhat detailed discussion of the routing table implementaion using eXtremeDB
 * could be found in the whitepaper "The Role of In-Memory Database Systems in Routing
 * Table Management in IP Routers" - http://mcobject.com/whitepapers.htm
 */

#include <platform.h>
#include <stdio.h>
#include <stdlib.h>

#include "rtdb.h"

static const char* dbname = "Route1";
static const int SEGSZ = 1024 * 1024 * 16UL;
#ifndef MCO_PLATFORM_X64
    static const int PAGESIZE = 96;
#else 
    static const int PAGESIZE = 192;
#endif 


const int MAP_ADDRESS = 0x20000000;

#define NROUTES    200000
#define NSEARCHES  500000

static void _SH_(void)
{

    char text[] = 
    {
        "\nThis sample demonstrate the use of eXtremeDB for the Routing Table\n"
            "Management software.The program measures the performance for routing\n"
            "randomly generates IP addresses, each masked with three masks - 255.255.0.0,\n"
            "255.255.255.0 or 255.255.255.255. We then insert these routes into the\n"
            "routing table.After the table is populated, the program searches for a route\n"
            "for a random packet.The algorithm is a combination of a linear search and\n"
            "a tree search, masking the address with each of the three possible masks and\n"
            "then using the index to locate the route.\n"
    };

    char text1[] = 
    {
        "Copyright (c) 2001-2007 McObject LLC. All Right Reserved.\n\n"
    };

    printf("%s\neXtremeDB runtime version %d.%d, build %d\n%s\n\nPress Enter to start", text, MCO_COMP_VER_MAJOR,
           MCO_COMP_VER_MINOR, MCO_COMP_BUILD_NUM, text1);

    getchar();
}


/* Produces database memory report
 */
void showMem(mco_db_h db)
{
    mco_puint freepg, totalpg;

    mco_db_free_pages(db, &freepg);
    mco_db_total_pages(db, &totalpg);

    printf("\n\tMemory Report:\n\ttotal pages=%d (%dK)\n\tfree pages=%d (%dK)\n\tused %dK\n", totalpg, totalpg*
           PAGESIZE / 1024, freepg, freepg* PAGESIZE / 1024, (totalpg - freepg)* PAGESIZE / 1024);
}


/* fatal error handler */
static void errhandler(int n)
{
    printf("\neXtremeDB fatal error: %d", n);
    getchar();
    exit( - 1);
}


static uint1 calcNbits(uint4 mask)
{
    static int n8[16] = 
    {
        0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4
    };
    int rc = 0, i;
    for (i = 0; i < 8; i++)
    {
        int halfbt = (mask >> (i << 2)) &15;
        rc += n8[halfbt];
    }
    return (uint1)rc;
}


static MCO_RET addRoute(mco_db_h db, uint4 dest, uint4 mask, uint4 gatew, uint4 interf, uint2 weight)
{
    MCO_RET rc;
    mco_trans_h t;
    Mask hmask;
    Route rt;
    uint1 nbit = calcNbits(mask);
    // mco_cursor_t csr;

    rc = mco_trans_start(db, MCO_READ_WRITE, MCO_TRANS_FOREGROUND, &t);
    if (rc)
    {
        return rc;
    }

    // add mask if need:
    rc = Mask_all_find(t, nbit, mask, &hmask);
    if (rc == MCO_S_NOTFOUND)
    {
        rc = Mask_new(t, &hmask);
        if (rc)
        {
            goto End;
        }
        Mask_mask_put(&hmask, mask);
        Mask_nbits_put(&hmask, nbit);
    }
    else
    {
        if (rc)
        {
            goto End;
        }
    }

    // add route:
    rc = Route_new(t, &rt);
    if (rc)
    {
        goto End;
    }

    Route_dest_put(&rt, dest);
    Route_mask_put(&rt, mask);
    Route_gateway_put(&rt, gatew);
    Route_interf_put(&rt, interf);
    Route_metric_put(&rt, weight);

    End: rc = mco_trans_commit(t);
    return rc;
}


static uint4 genIP(void)
{
    uint4 rc = 0x2A3B0000;
    int rn = rand() | (rand() << 16);

    rc |= rn &0xFFFFFF;
    if (rn &0x01000000)
    {
        rc |= 0x0E000000; // ^= (rn & 0x0F000000);
    }
    return rc;
}


static uint4 genMask(uint4 ip)
{
    int rn = rand() &15;
    if (rn < 12)
    {
        return 0xFFFFFFFF;
    }
    if (rn < 15)
    {
        return 0xFFFFFF00;
    }
    return 0xFFFF0000;
}


static const char* prtip(uint4 n)
{
    static char rc[100];
    sprintf(rc, "%03d.%03d.%03d.%03d  ", (n >> 24) &255, (n >> 16) &255, (n >> 8) &255, (n) &255);
    return rc;
}


/* This is used to dump the content of the routing table into the file
 * In oredr to use this, change the schema so, that the tree index is
 * declared, and remove the #define DUMP_TABLE on the top of this file
 */
//#define DUMP_TABLE
static void dumpRoutingTable(mco_db_h db, const char* fnm)
{
    #ifdef DUMP_TABLE
        FILE* f = fopen(fnm, "w");

        mco_cursor_t csr;
        Route rt;
        uint4 mask, dest, gateway, interf;
        mco_trans_h t;
        MCO_RET rc;

        if (!f)
        {
            return ;
        }

        mco_trans_start(db, MCO_READ_WRITE, MCO_TRANS_FOREGROUND, &t);

        Route_byMaskDest_index_cursor(t, &csr);

        for (rc = mco_cursor_first(t, &csr); rc == MCO_S_OK; rc = mco_cursor_next(t, &csr))
        {
            Route_from_cursor(t, &csr, &rt);
            Route_dest_get(&rt, &dest);
            Route_mask_get(&rt, &mask);
            Route_interf_get(&rt, &interf);
            Route_gateway_get(&rt, &gateway);

            fprintf(f, "%s", prtip(dest));
            fprintf(f, "%s", prtip(mask));
            fprintf(f, "%s", prtip(gateway));
            fprintf(f, "%s", prtip(interf));
            fprintf(f, "\n");

        }

        mco_trans_commit(t);
        fclose(f);
    #endif 
}


/* 
 * searchRoute()
 */
static int searchRoute(mco_db_h db, uint4 ip, uint4* res_gatew, uint4* res_interf)
{
    MCO_RET rc;
    mco_cursor_t csr;
    Mask hmask;
    uint4 mask;
    mco_trans_h t;

    int ok = 0;

    rc = mco_trans_start(db, MCO_READ_ONLY, MCO_TRANS_FOREGROUND, &t);
    if (rc)
    {
        return rc;
    }

    // scan all possible masks
    rc = Mask_all_index_cursor(t, &csr);
    if (rc)
    {
        goto End;
    }

    for (rc = mco_cursor_last(t, &csr); rc == MCO_S_OK; rc = mco_cursor_prev(t, &csr))
    {
        Route rt;

        Mask_from_cursor(t, &csr, &hmask);
        Mask_mask_get(&hmask, &mask);
        rc = Route_byMaskDest_find(t, mask, mask &ip, &rt);
        if (rc == MCO_S_OK)
        {
            ok = 1;
            break;
        }
    }

    End: rc = mco_trans_commit(t);
    return ok;

}


static void dodo(mco_db_h db)
{
    int j;
    MCO_RET rc;
    uint4 gway = genIP();
    uint4 interf = genIP();
    int nok = 0;
    int nskipped = 0;
    uint4 ip;
    uint4 mask;

    time_t t1, t2, t3, t4;

    printf("\nPopulating Routing Table with %d randomly generated routes\n", NROUTES);
    Sleep(50);
    time(&t1);
    for (j = 0; j < NROUTES; j++)
    {

        ip = genIP();
        mask = genMask(ip);
        ip = ip &mask;

        rc = addRoute(db, ip, mask, gway, interf, 1);

        if (rc)
        {
            if (rc == MCO_S_DUPLICATE)
            {
                nskipped++;
            }
            else
            {
                printf("\nRoute add error: %d", rc);
                break;
            }
        }
        if (j % 5000 == 0)
        {
            printf(".");
        }
    }
    time(&t2);

    printf("\nAdded %d routes, %d duplicate routes rejected -- %d sec\n\n", j - nskipped, nskipped, t2 - t1);
    Sleep(50);
    showMem(db);

    dumpRoutingTable(db, "rt_.txt");

    printf("\nLooking for a random IP %d times\n", NSEARCHES);
    Sleep(50);

    time(&t3);
    for (j = 0; j < NSEARCHES; j++)
    {
        uint4 ip = genIP();
        uint4 res_gatew, res_interf;
        int ok = searchRoute(db, ip, &res_gatew, &res_interf);
        if (ok)
        {
            nok++;
        }
        if (j % 5000 == 0)
        {
            printf(".");
        }
    }
    time(&t4);

    printf("\nSearched %d destinations -- %d sec -- %d succeeded\n\n", j, t4 - t3, nok);

}


int main(void)
{
    MCO_RET rc;
    mco_db_h db = 0;
    char* start_mem;
    mco_runtime_info_t info;

    _SH_();
    mco_get_runtime_info(&info);
    if (info.mco_shm_supported)
    {
        start_mem = (char*)MAP_ADDRESS;
    }
    else
    {
        start_mem = (char*)malloc(SEGSZ);
        if (!start_mem)
        {
            printf("Couldn't allocated memory\n");
            exit(1);
        }
    };

    /* set fatal error handler */
    mco_error_set_handler(&errhandler);

    rc = mco_runtime_start();

    /* Create a database, using first memory segment */
    rc = mco_db_open(dbname, rtdb_get_dictionary(), start_mem, SEGSZ, (uint2)PAGESIZE);

    if (rc)
    {
        printf("\nerror creating database");
        if (!info.mco_shm_supported)
        {
            free(start_mem);
        }
        exit(1);
    }

    /* connect to the database, obtain a database handle */
    mco_db_connect(dbname, &db);
    showMem(db);

    dodo(db);

    /* disconnect from the database, db is no longer valid */
    mco_db_disconnect(db);

    /* destroys the memory manager */
    mco_db_close(dbname);

    mco_runtime_stop();

    if (!info.mco_shm_supported)
    {
        free(start_mem);
    }

    printf("press Enter to finish \n");
    getchar();
    PROG_EXIT(0);
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品在线一区二区三区| 成人听书哪个软件好| 国产乱色国产精品免费视频| 99精品欧美一区二区蜜桃免费 | 亚洲成人资源网| 国产成人在线网站| 欧美日韩精品福利| 亚洲视频免费在线| 国产一区二区视频在线播放| 欧美视频自拍偷拍| 自拍偷拍亚洲激情| 国产一区在线看| 欧美一区二区三区思思人| 亚洲婷婷国产精品电影人久久| 久久不见久久见中文字幕免费| 欧美色偷偷大香| 椎名由奈av一区二区三区| 国产精品538一区二区在线| 91精品国产丝袜白色高跟鞋| 亚洲影视资源网| 91小视频免费看| 国产精品福利一区| 粉嫩高潮美女一区二区三区 | 日韩精品电影一区亚洲| 色天天综合色天天久久| 国产精品久久久久aaaa樱花| 国产一区亚洲一区| 欧美tickling网站挠脚心| 三级影片在线观看欧美日韩一区二区| av亚洲精华国产精华| 国产精品欧美一级免费| 丁香婷婷综合色啪| 国产精品美女久久福利网站 | 日本在线不卡视频一二三区| 欧美色手机在线观看| 一区二区三区在线视频播放| 在线观看欧美日本| 亚洲午夜免费福利视频| 精品视频1区2区| 热久久一区二区| 日韩欧美激情一区| 国产综合色视频| 久久精品一区蜜桃臀影院| 激情文学综合网| 国产视频在线观看一区二区三区| 国产一二三精品| 国产精品―色哟哟| 91成人免费在线| 天天操天天干天天综合网| 欧美一级在线视频| 国产一区二区三区在线观看精品 | 亚洲精品国产视频| 欧美色成人综合| 免费成人在线视频观看| 久久综合久久综合九色| 成人av动漫在线| 亚洲一区二区三区四区不卡| 在线综合视频播放| 国产高清不卡二三区| 亚洲视频在线一区二区| 欧美另类高清zo欧美| 狠狠色丁香久久婷婷综合_中| 国产亚洲精品久| 欧美婷婷六月丁香综合色| 日本欧美韩国一区三区| 国产亚洲制服色| 欧美日韩一区在线观看| 国产精品一卡二卡在线观看| 亚洲欧美乱综合| 精品国产91亚洲一区二区三区婷婷| 成人app在线观看| 男人的天堂亚洲一区| 国产精品三级av在线播放| 欧美久久久久免费| 成人av资源站| 日韩国产欧美视频| 国产精品伦一区二区三级视频| 欧美日韩一区二区三区四区五区| 国产大陆精品国产| 日韩精品一级中文字幕精品视频免费观看| 久久影院视频免费| 精品视频一区 二区 三区| 丁香婷婷综合激情五月色| 人人狠狠综合久久亚洲| 一区二区三区在线视频免费| 欧美激情一区不卡| 欧美videofree性高清杂交| 在线中文字幕一区二区| 成人午夜av影视| 精品一区二区三区免费| 香港成人在线视频| 亚洲男帅同性gay1069| 中文字幕巨乱亚洲| 精品国内二区三区| 91精品久久久久久久99蜜桃| 色综合久久中文字幕综合网| 处破女av一区二区| 国产精品主播直播| 国产在线精品一区二区夜色| 日本亚洲天堂网| 性久久久久久久| 亚洲一二三区不卡| 亚洲精品v日韩精品| 日韩伦理电影网| 国产精品国产三级国产普通话三级 | 亚洲欧美另类图片小说| 欧美高清在线一区| 国产午夜亚洲精品羞羞网站| 久久色成人在线| 精品国产3级a| 久久久久亚洲综合| 久久精品亚洲乱码伦伦中文| 精品国产髙清在线看国产毛片| 欧美日韩精品二区第二页| 欧美性生交片4| 在线一区二区观看| 欧美三电影在线| 欧美日韩国产免费一区二区 | 欧美日韩国产一级片| 欧美亚洲综合一区| 欧美日韩日日骚| 欧美老女人第四色| 欧美一二三四在线| 日韩区在线观看| 久久婷婷国产综合精品青草| 久久久亚洲午夜电影| 国产蜜臀av在线一区二区三区| 国产三区在线成人av| 国产精品理伦片| 亚洲色图20p| 天天射综合影视| 久久成人久久爱| 岛国精品在线播放| 91偷拍与自偷拍精品| 欧美精品一级二级三级| 日韩精品一区二区三区视频 | 欧美亚洲一区二区在线观看| 欧美在线免费观看视频| 欧美日韩在线播放一区| 欧美精品一级二级三级| 久久免费视频色| 中文字幕一区二区三区色视频| 亚洲愉拍自拍另类高清精品| 麻豆中文一区二区| 国产成人av网站| 欧美午夜精品一区二区蜜桃 | 国产午夜精品在线观看| 亚洲欧美日韩一区| 琪琪久久久久日韩精品| 成人久久久精品乱码一区二区三区 | 欧美美女喷水视频| 久久精品视频免费观看| 亚洲欧洲av在线| 三级在线观看一区二区| 成人一区二区在线观看| 911精品国产一区二区在线| 久久综合色之久久综合| 一区二区三区在线免费观看| 精品综合久久久久久8888| av不卡一区二区三区| 91麻豆精品91久久久久久清纯| 久久精品这里都是精品| 夜夜嗨av一区二区三区中文字幕| 狠狠久久亚洲欧美| 欧美性生活影院| 国产精品久久久久久久久图文区| 五月天中文字幕一区二区| 成人午夜碰碰视频| 日韩一区和二区| 亚洲二区视频在线| 成人福利视频在线看| 日韩欧美www| 亚洲电影一区二区三区| av电影在线观看完整版一区二区| 日韩欧美一卡二卡| 亚洲韩国精品一区| 成人h动漫精品一区二区| 精品国产伦一区二区三区观看体验 | 久久久综合精品| 日韩国产一二三区| 欧美三级电影网| 亚洲综合激情小说| 99久久精品国产一区| 国产色综合久久| 久久国产尿小便嘘嘘| 欧美精选一区二区| 亚洲第一主播视频| 在线亚洲高清视频| 亚洲日本va午夜在线电影| 风间由美一区二区av101| 久久综合狠狠综合久久综合88| 日本网站在线观看一区二区三区| 欧美视频一区在线观看| 亚洲欧美色一区| 色综合视频一区二区三区高清| 国产精品乱码一区二区三区软件 | 亚洲精品日韩一| 日本道精品一区二区三区| 亚洲图片激情小说| 91亚洲精品乱码久久久久久蜜桃|