[ovs-discuss] Implementing Stochastic Switching in ovs 2.5.5

ha Fa haiderfayeq80 at gmail.com
Tue Dec 4 12:45:59 UTC 2018


 hi,
am Haider Ph.D. student at Malaya University,

kindly,
i request help Please, am trying to implement Stochastic Switching in ovs
2.5.5. to implement select group type in OVS 2.5.5 randomly selects a bucket
from among the live buckets based on destination IP address.

as i read from this website
https://github.com/saeenali/openvswitch/wiki/Stochastic-Switching-using-Open-vSwitch-in-Mininet
.
But unfortunately this is implemented based on ovs 2.1 not 2.5.5, and based
on destination MAC.

is this code below

*static void
xlate_select_group(struct xlate_ctx *ctx, struct group_dpif *group)
{
    struct flow_wildcards *wc = &ctx->xout->wc;
    const struct ofputil_bucket *bucket;
    uint32_t basis;

    // The following tells the caching code that every packet in
    // the flow in question must go to the userspace "slow path".
    ctx->xout->slow |= SLOW_CONTROLLER;

    basis = hash_bytes(ctx->xin->flow.dl_dst, sizeof ctx->xin->flow.dl_dst, 0);
    bucket = group_best_live_bucket(ctx, group, basis);
    if (bucket) {
        memset(&wc->masks.dl_dst, 0xff, sizeof wc->masks.dl_dst);
        xlate_group_bucket(ctx, bucket);
    }
}

static const struct ofputil_bucket *
group_best_live_bucket(const struct xlate_ctx *ctx,
                   const struct group_dpif *group,
                   uint32_t basis) // basis in not being used
{
    uint32_t rand_num = 0, sum = 0;
    const struct ofputil_bucket *bucket = NULL;
    const struct list *buckets;

    // initialize random seed once
    if (!is_srand_initialized) {
        srand(time(NULL));
        is_srand_initialized = true;
    }

    // generate a random number in [1, 10]
    rand_num = (rand() % 10) + 1;

    group_dpif_get_buckets(group, &buckets);
    LIST_FOR_EACH (bucket, list_node, buckets) {
        if (bucket_is_alive(ctx, bucket, 0)) {
            sum += bucket->weight;
            if (rand_num <= sum) {
                return bucket; // return this bucket
            }
        }
    }

    return bucket; // return NULL
}*


can be used in ovs 2.5.5 and shall i replace

*memset(&wc->masks.dl_dst, 0xff, sizeof wc->masks.dl_dst);*

to* &wc->masks.nw_dst.*

I am highly appreciated for your help me in my Ph.D study*.*

thank you*.*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openvswitch.org/pipermail/ovs-discuss/attachments/20181204/bebf7d3a/attachment.html>


More information about the discuss mailing list