Commit df1f79d7 authored by Simon Pastor's avatar Simon Pastor Committed by Kevin Di Lallo
Browse files

net char package support latency, jitter, pkt loss

parent e20609e2
Loading
Loading
Loading
Loading
+50 −524

File changed.

Preview size limit exceeded, changes collapsed.

+253 −58

File changed.

Preview size limit exceeded, changes collapsed.

+4 −4
Original line number Diff line number Diff line
@@ -441,10 +441,10 @@ func validateNetCharUpdate(updatedNetCharList []FlowNetChar, src string, dst str
	for _, flowNetChar := range updatedNetCharList {
		if flowNetChar.DstElemName == dst &&
			flowNetChar.SrcElemName == src &&
			flowNetChar.Latency == latency &&
			flowNetChar.Jitter == jitter &&
			flowNetChar.PacketLoss == packetloss &&
			flowNetChar.Throughput == throughput {
			flowNetChar.MyNetChar.Latency == latency &&
			flowNetChar.MyNetChar.Jitter == jitter &&
			flowNetChar.MyNetChar.PacketLoss == packetloss &&
			flowNetChar.MyNetChar.Throughput == throughput {
			found = true
			break
		}
+17 −10
Original line number Diff line number Diff line
@@ -35,10 +35,11 @@ const moduleName string = "meep-net-char"

// NetChar Interface
type NetCharMgr interface {
	Register(func(string, string, float64), func())
	Register(func(string, string, float64, float64, float64, float64), func())
	Start() error
	Stop()
	IsRunning() bool
	ProcessActiveScenarioUpdate()
}

// NetCharAlgo
@@ -48,16 +49,21 @@ type NetCharAlgo interface {
	SetConfigAttribute(string, string)
}

// FlowNetChar
type FlowNetChar struct {
	SrcElemName string
	DstElemName string
// NetChar
type NetChar struct {
	Latency    float64
	Jitter     float64
	PacketLoss float64
	Throughput float64
}

// FlowNetChar
type FlowNetChar struct {
	SrcElemName string
	DstElemName string
	MyNetChar   NetChar
}

// NetCharConfig
type NetCharConfig struct {
	Action              string
@@ -74,7 +80,7 @@ type NetCharManager struct {
	mutex          sync.Mutex
	config         NetCharConfig
	activeModel    *mod.Model
	updateFilterCB func(string, string, float64)
	updateFilterCB func(string, string, float64, float64, float64, float64)
	applyFilterCB  func()
	algo           NetCharAlgo
}
@@ -138,7 +144,7 @@ func NewNetChar(name string, redisAddr string) (*NetCharManager, error) {
}

// Register - Register NetChar callback functions
func (ncm *NetCharManager) Register(updateFilterRule func(string, string, float64), applyFilterRule func()) {
func (ncm *NetCharManager) Register(updateFilterRule func(string, string, float64, float64, float64, float64), applyFilterRule func()) {
	ncm.updateFilterCB = updateFilterRule
	ncm.applyFilterCB = applyFilterRule
}
@@ -147,6 +153,7 @@ func (ncm *NetCharManager) Register(updateFilterRule func(string, string, float6
func (ncm *NetCharManager) Start() error {
	if !ncm.isStarted {
		ncm.isStarted = true
		ncm.updateControls()
		ncm.ticker = time.NewTicker(time.Duration(ncm.config.RecalculationPeriod) * time.Millisecond)
		go func() {
			for range ncm.ticker.C {
@@ -186,7 +193,7 @@ func (ncm *NetCharManager) eventHandler(channel string, payload string) {
		ncm.updateControls()
	case mod.ActiveScenarioEvents:
		log.Debug("Event received on channel: ", mod.ActiveScenarioEvents)
		ncm.processActiveScenarioUpdate()
//		ncm.processActiveScenarioUpdate()
	default:
		log.Warn("Unsupported channel")
	}
@@ -194,7 +201,7 @@ func (ncm *NetCharManager) eventHandler(channel string, payload string) {
}

// processActiveScenarioUpdate
func (ncm *NetCharManager) processActiveScenarioUpdate() {
func (ncm *NetCharManager) ProcessActiveScenarioUpdate() {
	if ncm.isStarted {
		// Process updated scenario using algorithm
		err := ncm.algo.ProcessScenario(ncm.activeModel)
@@ -216,7 +223,7 @@ func (ncm *NetCharManager) updateNetChars() {
	// Apply updates, if any
	if len(updatedNetCharList) != 0 {
		for _, flowNetChar := range updatedNetCharList {
			ncm.updateFilterCB(flowNetChar.DstElemName, flowNetChar.SrcElemName, flowNetChar.Throughput)
			ncm.updateFilterCB(flowNetChar.DstElemName, flowNetChar.SrcElemName, flowNetChar.MyNetChar.Throughput, flowNetChar.MyNetChar.Latency, flowNetChar.MyNetChar.Jitter, flowNetChar.MyNetChar.PacketLoss)
		}
		ncm.applyFilterCB()
	}