当前位置: 首页>>代码示例>>C++>>正文


C++ Flow::start_rate_generator方法代码示例

本文整理汇总了C++中Flow::start_rate_generator方法的典型用法代码示例。如果您正苦于以下问题:C++ Flow::start_rate_generator方法的具体用法?C++ Flow::start_rate_generator怎么用?C++ Flow::start_rate_generator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Flow的用法示例。


在下文中一共展示了Flow::start_rate_generator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: flows_throught_domains_streaming

// domains than flows
// THIS THE MOST FUCKING COMPLEX FUNCTION IN THIS MODEL
int GCN::flows_throught_domains_streaming(float time)
{
    map<int, Domain*>::iterator domain_map_iter;

    for(domain_map_iter = domain_map.begin(); domain_map_iter != domain_map.end(); ++domain_map_iter)
    {
        Domain* domain;
        int domain_id = domain_map_iter->first;
        domain = domain_map_iter->second;

        map<int, Flow*>::iterator flow_map_iter;
        int domain_for_flow_type;
        for(flow_map_iter = flow_map.begin(); flow_map_iter != flow_map.end(); ++flow_map_iter)
        {
            Flow* flow;
            int flow_id = flow_map_iter->first;
            flow = flow_map_iter->second;
            domain_for_flow_type = flow->get_domain_type_for_this_flow(domain_id);

            if(domain_for_flow_type == 0) // start domain for this flow
            {
                float start_rate = flow->start_rate_generator();
                float overload = domain->add_load(flow_id, start_rate); // change domain load... overload may be NULL
                flow->change_state(domain_id,start_rate - overload,overload,0.0f); // change flow state at this domain
                //change domains vuln host number
                if(flow->is_malware())
                {
                    Malware* malware;
                    malware = malware_map[flow->get_flow_malware_id()];
                    domain->change_inf_hosts_number(flow->get_flow_malware_id(),start_rate,
                                                    malware->get_copy_size(),malware->get_infection_speed());
                }
            }
            else if (domain_for_flow_type == 1) // transit domain for this flow
            {
                int prev_domain_id = flow->get_prev_domain_in_flow_path(domain_id);
                Link* link = this->get_link(prev_domain_id,domain_id);
                Domain* prev_domain = domain_map[prev_domain_id];
                float flow_rate_in_prev_domain = prev_domain->get_flow_res(flow_id); // see how muck ress this flow took in prev domain

                float transfer_rate; // next stage to calc transfer rate for this flow
                float link_bandwidth = link->get_bandwidth(); // general link bandwidth
                int link_id = link->get_link_id(); // link id
                float tick_link_bandwidth = tick_link_state_map[link_id]; // current tick link bandwidth
                if(flow_rate_in_prev_domain > (link_bandwidth - tick_link_bandwidth))
                    transfer_rate = link_bandwidth - tick_link_bandwidth; // we cant transfer more then link allowed
                else
                    transfer_rate = flow_rate_in_prev_domain;

                //change domains (curr and prev) load
                prev_domain->sub_load(flow_id,transfer_rate);
                domain->add_load(flow_id,transfer_rate);

                //change domains vuln host number
                if(flow->is_malware())
                {
                    Malware* malware;
                    malware = malware_map[flow->get_flow_malware_id()];
                    domain->change_inf_hosts_number(flow->get_flow_malware_id(),transfer_rate,
                                                    malware->get_copy_size(),malware->get_infection_speed());
                }

                //change tick link state
                tick_link_state_map[link_id] += transfer_rate;
            }
            else if (domain_for_flow_type == 2) // last domain for this flow
            {

                int prev_domain_id = flow->get_prev_domain_in_flow_path(domain_id);
                Link* link = this->get_link(prev_domain_id,domain_id);

                Domain* prev_domain = domain_map[prev_domain_id];
                float flow_rate_in_prev_domain = prev_domain->get_flow_res(flow_id); // see how muck ress this flow took in prev domain

                float transfer_rate; // next stage to calc transfer rate for this flow
                float link_bandwidth = link->get_bandwidth(); // general link bandwidth
                int link_id = link->get_link_id(); // link id
                float tick_link_bandwidth = tick_link_state_map[link_id]; // current tick link bandwidth
                if(flow_rate_in_prev_domain > (link_bandwidth - tick_link_bandwidth))
                    transfer_rate = link_bandwidth - tick_link_bandwidth; // we cant transfer more then link allowed
                else
                    transfer_rate = flow_rate_in_prev_domain;

                //change domains (curr and prev) load
                prev_domain->sub_load(flow_id,transfer_rate); // NO ADD LOAD - becouse of consume

                //change domains vuln host number
                if(flow->is_malware())
                {
                    Malware* malware;
                    malware = malware_map[flow->get_flow_malware_id()];
                    domain->change_inf_hosts_number(flow->get_flow_malware_id(),transfer_rate,
                                                    malware->get_copy_size(),malware->get_infection_speed());
                }

                //change tick link state
                tick_link_state_map[link_id] += transfer_rate;
            }
//.........这里部分代码省略.........
开发者ID:anvial,项目名称:SystemModel,代码行数:101,代码来源:gcn.cpp


注:本文中的Flow::start_rate_generator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。