Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev bitrate changes #59

Merged
merged 4 commits into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 47 additions & 12 deletions configapi/api_slice_mgmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@
package configapi

import (
"math"
"strings"

"github.com/free5gc/http_wrapper"
"github.com/gin-gonic/gin"
"github.com/omec-project/webconsole/backend/logger"
"github.com/omec-project/webconsole/configmodels"
"github.com/sirupsen/logrus"
"math"
"strings"
)

const (
KPS = 1000
MPS = 1000000
GPS = 1000000000
)

var configChannel chan *configmodels.ConfigMessage
Expand Down Expand Up @@ -44,6 +51,19 @@ func DeviceGroupDeleteHandler(c *gin.Context) bool {

}

func convertToBps(val int64, unit string) (bitrate int64) {
if strings.EqualFold(unit, "kbps") {
bitrate = val * KPS
} else if strings.EqualFold(unit, "mbps") {
bitrate = val * MPS
} else if strings.EqualFold(unit, "gbps") {
bitrate = val * GPS
} else {
// default consider it as mbps
bitrate = val * MPS
}
return bitrate
}
func DeviceGroupPostHandler(c *gin.Context, msgOp int) bool {
var groupName string
var exists bool
Expand Down Expand Up @@ -84,11 +104,11 @@ func DeviceGroupPostHandler(c *gin.Context, msgOp int) bool {
configLog.Infof(" ip mtu : %v", ipdomain.Mtu)
configLog.Infof("Device Group Name : %v ", groupName)
if ipdomain.UeDnnQos != nil {
ipdomain.UeDnnQos.DnnMbrDownlink = ipdomain.UeDnnQos.DnnMbrDownlink * 1000000
ipdomain.UeDnnQos.DnnMbrDownlink = convertToBps(ipdomain.UeDnnQos.DnnMbrDownlink, ipdomain.UeDnnQos.BitrateUnit)
if ipdomain.UeDnnQos.DnnMbrDownlink < 0 {
ipdomain.UeDnnQos.DnnMbrDownlink = math.MaxInt64
}
ipdomain.UeDnnQos.DnnMbrUplink = ipdomain.UeDnnQos.DnnMbrUplink * 1000000
ipdomain.UeDnnQos.DnnMbrUplink = convertToBps(ipdomain.UeDnnQos.DnnMbrUplink, ipdomain.UeDnnQos.BitrateUnit)
if ipdomain.UeDnnQos.DnnMbrUplink < 0 {
ipdomain.UeDnnQos.DnnMbrUplink = math.MaxInt64
}
Expand Down Expand Up @@ -156,14 +176,20 @@ func NetworkSlicePostHandler(c *gin.Context, msgOp int) bool {
configLog.Infof(" sd : %v", slice.Sd)

qos := &procReq.Qos
qos.Uplink = qos.Uplink * 1000000
if qos.Uplink < 0 {
bitrate := convertToBps(int64(qos.Uplink), qos.BitrateUnit)
if bitrate < 0 || bitrate > math.MaxInt32 {
qos.Uplink = math.MaxInt32
} else {
qos.Uplink = int32(bitrate)
}
qos.Downlink = qos.Downlink * 1000000
if qos.Downlink < 0 {

bitrate = convertToBps(int64(qos.Downlink), qos.BitrateUnit)
if bitrate < 0 || bitrate > math.MaxInt32 {
qos.Downlink = math.MaxInt32
} else {
qos.Downlink = int32(bitrate)
}

configLog.Infof("Slice QoS ")
configLog.Infof(" uplink bps : %v", qos.Uplink)
configLog.Infof(" downlink bps : %v", qos.Downlink)
Expand Down Expand Up @@ -210,13 +236,22 @@ func NetworkSlicePostHandler(c *gin.Context, msgOp int) bool {
configLog.Infof("\tProtocol : %v", filter.Protocol)
configLog.Infof("\tStart Port : %v", filter.StartPort)
configLog.Infof("\tEnd Port : %v", filter.EndPort)
procReq.ApplicationFilteringRules[index].AppMbrUplink = procReq.ApplicationFilteringRules[index].AppMbrUplink * 1000000
if procReq.ApplicationFilteringRules[index].AppMbrUplink < 0 {
ul := procReq.ApplicationFilteringRules[index].AppMbrUplink
dl := procReq.ApplicationFilteringRules[index].AppMbrDownlink
unit := procReq.ApplicationFilteringRules[index].BitrateUnit

bitrate := convertToBps(int64(ul), unit)
if bitrate < 0 || bitrate > math.MaxInt32 {
procReq.ApplicationFilteringRules[index].AppMbrUplink = math.MaxInt32
} else {
procReq.ApplicationFilteringRules[index].AppMbrUplink = int32(bitrate)
}
procReq.ApplicationFilteringRules[index].AppMbrDownlink = procReq.ApplicationFilteringRules[index].AppMbrDownlink * 1000000
if procReq.ApplicationFilteringRules[index].AppMbrDownlink < 0 {

bitrate = convertToBps(int64(dl), unit)
if bitrate < 0 || bitrate > math.MaxInt32 {
procReq.ApplicationFilteringRules[index].AppMbrDownlink = math.MaxInt32
} else {
procReq.ApplicationFilteringRules[index].AppMbrDownlink = int32(bitrate)
}

configLog.Infof("\tApp MBR Uplink : %v", procReq.ApplicationFilteringRules[index].AppMbrUplink)
Expand Down
3 changes: 3 additions & 0 deletions configmodels/model_application_filtering_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ type SliceApplicationFilteringRules struct {

AppMbrDownlink int32 `json:"app-mbr-downlink,omitempty"`

// data rate unit for uplink and downlink
BitrateUnit string `json:"bitrate-unit,omitempty"`

TrafficClass *TrafficClassInfo `json:"traffic-class,omitempty"`

RuleTrigger string `json:"rule-trigger,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ package configmodels

// DeviceGroupsIpDomainExpandedUeDnnQos struct for DeviceGroupsIpDomainExpandedUeDnnQos
type DeviceGroupsIpDomainExpandedUeDnnQos struct {
// uplink data rate in bps
// uplink data rate
DnnMbrUplink int64 `json:"dnn-mbr-uplink,omitempty"`
// downlink data rate in bps
// downlink data rate
DnnMbrDownlink int64 `json:"dnn-mbr-downlink,omitempty"`
// data rate unit for uplink and downlink
BitrateUnit string `json:"bitrate-unit,omitempty"`
// QCI/QFI for the traffic
TrafficClass *TrafficClassInfo `json:"traffic-class,omitempty"`
}
17 changes: 9 additions & 8 deletions configmodels/model_flow_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
package configmodels

type FlowRule struct {
Filter string `json:"filter,omitempty" yaml:"filter" bson:"filter" mapstructure:"filter"`
Snssai string `json:"snssai,omitempty" yaml:"snssai" bson:"snssai" mapstructure:"snssai"`
Dnn string `json:"dnn,omitempty" yaml:"v" bson:"dnn" mapstructure:"dnn"`
Var5QI int `json:"5qi,omitempty" yaml:"5qi" bson:"5qi" mapstructure:"5qi"`
MBRUL string `json:"mbrUL,omitempty" yaml:"mbrUL" bson:"mbrUL" mapstructure:"mbrUL"`
MBRDL string `json:"mbrDL,omitempty" yaml:"mbrDL" bson:"mbrDL" mapstructure:"mbrDL"`
GBRUL string `json:"gbrUL,omitempty" yaml:"gbrUL" bson:"gbrUL" mapstructure:"gbrUL"`
GBRDL string `json:"gbrDL,omitempty" yaml:"gbrDL" bson:"gbrDL" mapstructure:"gbrDL"`
Filter string `json:"filter,omitempty" yaml:"filter" bson:"filter" mapstructure:"filter"`
Snssai string `json:"snssai,omitempty" yaml:"snssai" bson:"snssai" mapstructure:"snssai"`
Dnn string `json:"dnn,omitempty" yaml:"v" bson:"dnn" mapstructure:"dnn"`
Var5QI int `json:"5qi,omitempty" yaml:"5qi" bson:"5qi" mapstructure:"5qi"`
MBRUL string `json:"mbrUL,omitempty" yaml:"mbrUL" bson:"mbrUL" mapstructure:"mbrUL"`
MBRDL string `json:"mbrDL,omitempty" yaml:"mbrDL" bson:"mbrDL" mapstructure:"mbrDL"`
GBRUL string `json:"gbrUL,omitempty" yaml:"gbrUL" bson:"gbrUL" mapstructure:"gbrUL"`
GBRDL string `json:"gbrDL,omitempty" yaml:"gbrDL" bson:"gbrDL" mapstructure:"gbrDL"`
BitRateUnit string `json:"bitrate-unit,iyaml:"bitrate-unit" bson:"bitrate-unit" mapstructure:"bitrate-unit" omitempty"`
}
1 change: 1 addition & 0 deletions configmodels/model_slice_apn_ambr_qos.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ package configmodels
type ApnAmbrQosInfo struct {
Uplink int32 `json:"uplink-mbr,omitempty"`
Downlink int32 `json:"downlink-mbr,omitempty"`
BitRateUnit string `json:"bitrate-unit,omitempty"`
TrafficClass string `json:"traffic-class,omitempty"`
}
3 changes: 3 additions & 0 deletions configmodels/model_slice_qos.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ type SliceQos struct {
// downlink data rate in bps
Downlink int32 `json:"downlink,omitempty"`

// data rate unit for uplink and downlink
BitrateUnit string `json:"bitrate-unit,omitempty"`

// QCI/QFI for the traffic
TrafficClass string `json:"traffic-class,omitempty"`
}
12 changes: 10 additions & 2 deletions proto/server/clientEvtHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,8 +612,16 @@ func postConfigMme(client *clientNF) {

//keys.ServingPlmn.Tac = gnb.Tac
plmn := "mcc=" + siteInfo.Plmn.Mcc + ", mnc=" + siteInfo.Plmn.Mnc
client.clientLog.Infof("plmn for mme %v", plmn)
config.PlmnList = append(config.PlmnList, plmn)
var found bool
for _, p := range config.PlmnList {
if p == plmn {
found = true
}
}
if !found {
client.clientLog.Infof("Adding plmn for mme %v", plmn)
config.PlmnList = append(config.PlmnList, plmn)
}
}
client.clientLog.Infoln("Config sending to mme:")
b, err := json.Marshal(config)
Expand Down