Commit 604b6306 authored by Simon Pastor's avatar Simon Pastor
Browse files

pull request #23 comments applied

parent 63ef0948
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -238,7 +238,7 @@ func Init() (err error) {
		return err
	}
	bwSharing.UpdateControls()
	_ = bwSharing.Start()
	//	_ = bwSharing.Start()

	// Initialize TC Engine with current active scenario & LB rules
	processActiveScenarioUpdate()
@@ -1493,12 +1493,14 @@ func connectToAPISvr() (*kubernetes.Clientset, error) {
	return clientset, nil
}

// Used to print network characteristics belonging to a NetChar object -- uncomment to use -- for debug purpose
// func printfNetChar(nc NetChar) {
//      log.Debug("latency : ", nc.Latency, "~", nc.LatencyVariation, "|", nc.LatencyCorrelation)
//      log.Debug("throughput : ", nc.Throughput)
//      log.Debug("packet loss: ", nc.PacketLoss)
// }
//
// Used to print all the element information belonging to an NetElem object -- uncomment to use -- for debug purpose
// func printfElement(element NetElem) {
//      log.Debug("element name : ", element.Name)
//      log.Debug("element index : ", element.Index)
@@ -1524,12 +1526,14 @@ func connectToAPISvr() (*kubernetes.Clientset, error) {
//      log.Debug("element next unique nb: ", element.NextUniqueNumber)
// }
//
// Used to print filtersInfo from a list -- uncomment to use -- for debug purpose
// func printfFilterInfoList(filterInfoList []FilterInfo) {
//      for _, filterInfo := range filterInfoList {
//              printfFilterInfo(filterInfo)
//      }
// }
//
// Used to print all the filterInfo attributes belonging to a FilterInfo object -- uncomment to use -- for debug purpose
// func printfFilterInfo(filterInfo FilterInfo) {
//      log.Debug("***")
//      log.Debug("filterInfo PodName : ", filterInfo.PodName)
+4 −20
Original line number Diff line number Diff line
@@ -62,6 +62,8 @@ type stat struct {

const moduleMetrics string = "metrics"

var elasticLogPacing uint

func (u *destination) ping(pinger *Pinger) {
	rtt, err := pinger.Ping(u.remote, opts.timeout)
	if err != nil {
@@ -150,8 +152,6 @@ func (u *destination) compute(rc *redis.Connector) (st stat) {
	return
}

var elasticPacing int

func (u *destination) processRxTx(rc *redis.Connector) {

	str := "tc -s qdisc show dev ifb" + u.ifbNumber
@@ -207,20 +207,6 @@ func (u *destination) processRxTx(rc *redis.Connector) {
	}

	var throughputStr, throughputVal string
	/*
	   if throughput > 1000 {
	           if throughput > 1000000 {
	                   throughputVal = strconv.FormatFloat(throughput/1000000, 'f', 3, 64)
	                   throughputStr = throughputVal + " Mbps"
	           } else {
	                   throughputVal = strconv.FormatFloat(throughput/1000, 'f', 3, 64)
	                   throughputStr = throughputVal + " Kbps"
	           }
	   } else {
	           throughputVal = strconv.FormatFloat(throughput, 'f', 3, 64)
	           throughputStr = throughputVal + " bps"
	   }
	*/
	//all the throughput in Mbps
	throughputVal = strconv.FormatFloat(throughput/1000000, 'f', 3, 64)
	throughputStr = throughputVal + " Mbps"
@@ -248,10 +234,8 @@ func (u *destination) processRxTx(rc *redis.Connector) {
	_ = rc.SetEntry(moduleMetrics+":"+PodName+":throughput", throughputStats)

	//pacing the logs in ES
	//assuming the traffic interval is every 100ms, we don't need to log that often in ES
	elasticPacing++

	if elasticPacing%10 == 0 {
	elasticLogPacing++
	if elasticLogPacing%opts.trafficIntervalsPerLog == 0 {
		log.WithFields(log.Fields{
			"meep.log.component":     "sidecar",
			"meep.log.msgType":       "ingressPacketStats",
+19 −36
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ var opts = struct {
	timeout                time.Duration
	interval               time.Duration
	trafficInterval        time.Duration
	trafficIntervalsPerLog uint
	payloadSize            uint
	statBufferSize         uint
	bind4                  string
@@ -85,6 +86,7 @@ var opts = struct {
	timeout:                100000 * time.Millisecond,
	interval:               1000 * time.Millisecond,
	trafficInterval:        100 * time.Millisecond,
	trafficIntervalsPerLog: 10, //set to 10 to have one log per second, in order to lower the impact on Elastic Search
	bind4:                  "0.0.0.0",
	bind6:                  "::",
	payloadSize:            56,
@@ -611,25 +613,6 @@ func createIfbsHandler(key string, fields map[string]string, userData interface{
	return nil
}

/*
func flushFilters() {

        // NOTE: Flush does not work on kernel version 4.4
        //       Workaround is to manually remove all installed filters

        // err := cmdDeleteAllFilters()
        // if err != nil {
        //      return err
        // }
        // return nil

        for _, filterNumber := range filters {
                _ = cmdDeleteFilter(filterNumber)
        }
        filters = map[string]string{}
}
*/

func createFilters() error {
	keyName := moduleTcEngine + ":" + typeNet + ":" + PodName + ":filter*"
	err := rc.ForEachEntry(keyName, createFiltersHandler, nil)
+103 −97
Original line number Diff line number Diff line
/*
 * Copyright (c) 2019
 * InterDigital Communications, Inc.
 * All rights reserved.
 * Copyright (c) 2019  InterDigital Communications, Inc
 *
 * The information provided herein is the proprietary and confidential
 * information of InterDigital Communications, Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package bws

import (
	"errors"
	"time"
	"sync"
	"strconv"
	"sync"
	"time"

	ceModel "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-ctrl-engine-model"
	log "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger"
	redis "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-redis"

)

const redisAddr string = "meep-redis-master:6379"

var BW_SHARING_CONTROLS_DB = 0

// BwSharing -
@@ -93,7 +100,6 @@ func (bw *BwSharing) InitDefaultConfigAttributes() {
	initDefaultConfigAttributes()
}


// Run - Listening event
func (bw *BwSharing) Run() {
	// Listen for subscribed events. Provide event handler method.
@@ -159,7 +165,7 @@ func (bw *BwSharing) getControlsEntryHandler(key string, fields map[string]strin
	enableTier3 := false

	for fieldName, fieldValue := range fields {
		switch(fieldName) {
		switch fieldName {
		case "action":
			actionName = fieldValue
		case "recalculationPeriod":
@@ -191,7 +197,7 @@ func (bw *BwSharing) getControlsEntryHandler(key string, fields map[string]strin

// ApplyAction - Execute the action in the configuration parameters for controls on the bws object
func (bw *BwSharing) ApplyAction() (err error) {
        switch(bw.config.Action) {
	switch bw.config.Action {
	case "start":
		if !bw.isStarted {
			bw.Start()
+12 −7
Original line number Diff line number Diff line
/*
 * Copyright (c) 2019
 * InterDigital Communications, Inc.
 * All rights reserved.
 * Copyright (c) 2019  InterDigital Communications, Inc
 *
 * The information provided herein is the proprietary and confidential
 * information of InterDigital Communications, Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package bws
@@ -20,5 +27,3 @@ const typeActive string = "active"

const channelCtrlActive string = moduleCtrlEngine + "-" + typeActive
const channelBwSharingControls string = bwSharingControls

Loading