From fff34f395c39601272bee158312de82f97479161 Mon Sep 17 00:00:00 2001 From: gab-arrobo Date: Thu, 3 Oct 2024 12:25:33 -0700 Subject: [PATCH] Replace `logrus` with `zap` logger (#232) Signed-off-by: Arrobo, Gabriel --- .fossa.yml | 20 ---- VERSION | 2 +- common/events_test.go | 17 --- config/gnbsim.yaml | 8 +- factory/factory.go | 6 +- gnbsim.go | 28 +++-- gnodeb/context/gnbamf.go | 14 +-- gnodeb/context/gnbcpue.go | 17 ++- gnodeb/context/gnbpeerdao.go | 10 +- gnodeb/context/gnbuedao.go | 16 +-- gnodeb/context/gnbupf.go | 9 +- gnodeb/context/gnbupue.go | 17 ++- gnodeb/context/gnodeb.go | 4 +- gnodeb/gnodeb.go | 16 +-- gnodeb/transport/cptransport.go | 28 ++--- gnodeb/transport/uptransport.go | 14 +-- gnodeb/worker/gnbamfworker/handler.go | 70 +++++------ gnodeb/worker/gnbcpueworker/handler.go | 41 ++++--- gnodeb/worker/gnbcpueworker/worker.go | 4 +- gnodeb/worker/gnbupfworker/handler.go | 2 +- gnodeb/worker/gnbupfworker/worker.go | 2 +- gnodeb/worker/gnbupueworker/handler.go | 12 +- go.mod | 28 ++--- go.sum | 62 ++++------ httpserver/server.go | 11 +- logger/logger.go | 156 +++++++++++++------------ profile/context/profile.go | 24 ++-- profile/httprouter/handler.go | 10 +- profile/httprouter/router.go | 4 +- profile/ngsetup/ngsetup.go | 3 +- profile/profile.go | 14 +-- realue/context/pdusession.go | 11 +- realue/context/realue.go | 24 ++-- realue/handler.go | 34 +++--- realue/nas/nas_security.go | 24 ++-- realue/realue.go | 2 +- realue/worker/pdusessworker/handler.go | 24 ++-- simue/context/simue.go | 8 +- simue/handler.go | 50 ++++---- simue/simue.go | 24 ++-- util/test/gtp.go | 6 +- 41 files changed, 401 insertions(+), 475 deletions(-) delete mode 100755 .fossa.yml diff --git a/.fossa.yml b/.fossa.yml deleted file mode 100755 index 2555e058..00000000 --- a/.fossa.yml +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright 2020-present Open Networking Foundation -# -# SPDX-License-Identifier: Apache-2.0 -# -# Generated by FOSSA CLI (https://github.com/fossas/fossa-cli) -# Visit https://fossa.com to learn more -# -# Usage: FOSSA_API_KEY=<> fossa analyze -# -T is not supported at this moment from fossa side. -version: 2 -cli: - server: https://app.fossa.com - fetcher: custom - project: gnbsim -analyze: - modules: - - name: gnbsim - type: raw - target: ../gnbsim - path: ../gnbsim diff --git a/VERSION b/VERSION index 593d9b29..bc80560f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.4.6-dev +1.5.0 diff --git a/common/events_test.go b/common/events_test.go index 53b475bf..46b0da0c 100644 --- a/common/events_test.go +++ b/common/events_test.go @@ -4,12 +4,8 @@ package common import ( - "bytes" "fmt" "testing" - - "github.com/omec-project/gnbsim/logger" - "github.com/stretchr/testify/assert" ) func TestString_ValidEventTypeReturnsEventTypeString(t *testing.T) { @@ -25,16 +21,3 @@ func TestString_ValidEventTypeReturnsEventTypeString(t *testing.T) { ) } } - -func TestString_InvalidEventTypeExitsWithLogMsg(t *testing.T) { - var INVALID_EVENT EventType = 0x0 - var logBuf bytes.Buffer - assert := assert.New(t) - patchedExit := func(int) { panic("Dummy exit function") } - - logger.AppLog.Logger.SetOutput(&logBuf) - logger.AppLog.Logger.ExitFunc = patchedExit - - assert.Panics(func() { _ = INVALID_EVENT.String() }) - assert.Contains(logBuf.String(), "Invalid Event ID: 0x0") -} diff --git a/config/gnbsim.yaml b/config/gnbsim.yaml index 434c5aa8..cc389bda 100644 --- a/config/gnbsim.yaml +++ b/config/gnbsim.yaml @@ -29,7 +29,7 @@ configuration: plmnId: mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9) mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9) - gNbId: + gNbId: bitLength: 24 gNBValue: 000102 # gNB identifier (3 bytes hex string, range: 000000~FFFFFF) supportedTaList: @@ -54,7 +54,7 @@ configuration: profileType: custom # profile type profileName: custom1 # uniqely identifies a profile within application enable: false # Set true to execute the profile, false otherwise. - execInParallel: false #run all subscribers in parallel + execInParallel: false #run all subscribers in parallel stepTrigger: true #wait for trigger to move to next step gnbName: gnb1 # gNB to be used for this profile startImsi: 208930100007487 @@ -159,7 +159,7 @@ configuration: execInParallel: false #run all subscribers within profile in parallel plmnId: # Public Land Mobile Network ID, = . Should match startImsi mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9) - mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9) + mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9) - profileType: deregister # profile type profileName: profile5 # uniqely identifies a profile within application enable: false # Set true to execute the profile, false otherwise. @@ -235,4 +235,4 @@ configuration: mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9) logger: - logLevel: info # how detailed the log will be, values: trace, debug, info, warn, error, fatal, panic + logLevel: info # how detailed the log will be, values: debug, info, warn, error, fatal, panic diff --git a/factory/factory.go b/factory/factory.go index da7da307..d7113475 100644 --- a/factory/factory.go +++ b/factory/factory.go @@ -23,7 +23,7 @@ var AppConfig *Config func InitConfigFactory(f string) error { content, err := os.ReadFile(f) if err != nil { - logger.CfgLog.Errorln("Failed to read", f, "file:", err) + logger.CfgLog.Errorln("failed to read", f, "file:", err) return err } @@ -31,13 +31,13 @@ func InitConfigFactory(f string) error { err = yaml.Unmarshal(content, AppConfig) if err != nil { - logger.CfgLog.Errorln("Failed to unmarshal:", err) + logger.CfgLog.Errorln("failed to unmarshal:", err) return err } err = AppConfig.Validate() if err != nil { - logger.CfgLog.Errorln("Invalid Configuration:", err) + logger.CfgLog.Errorln("invalid Configuration:", err) } return err diff --git a/gnbsim.go b/gnbsim.go index 98a110da..67f3c8fd 100644 --- a/gnbsim.go +++ b/gnbsim.go @@ -25,6 +25,7 @@ import ( profctx "github.com/omec-project/gnbsim/profile/context" "github.com/omec-project/gnbsim/stats" "github.com/urfave/cli" + "go.uber.org/zap/zapcore" ) func main() { @@ -37,7 +38,7 @@ func main() { logger.AppLog.Infoln("App Name:", app.Name) if err := app.Run(os.Args); err != nil { - logger.AppLog.Errorln("Failed to run GNBSIM:", err) + logger.AppLog.Errorln("failed to run GNBSIM:", err) return } } @@ -45,13 +46,13 @@ func main() { func action(c *cli.Context) error { cfg := c.String("cfg") if cfg == "" { - logger.AppLog.Warnln("No configuration file provided. Using default configuration file:", factory.GNBSIM_DEFAULT_CONFIG_PATH) - logger.AppLog.Infoln("Application Usage:", c.App.Usage) + logger.AppLog.Warnln("no configuration file provided. Using default configuration file:", factory.GNBSIM_DEFAULT_CONFIG_PATH) + logger.AppLog.Infoln("application usage:", c.App.Usage) cfg = factory.GNBSIM_DEFAULT_CONFIG_PATH } if err := factory.InitConfigFactory(cfg); err != nil { - logger.AppLog.Errorln("Failed to initialize config factory:", err) + logger.AppLog.Errorln("failed to initialize config factory:", err) return err } @@ -61,26 +62,29 @@ func action(c *cli.Context) error { if config.Configuration.GoProfile.Enable { go func() { endpt := fmt.Sprintf(":%v", config.Configuration.GoProfile.Port) - fmt.Println("endpoint for profile server ", endpt) + logger.AppLog.Infoln("endpoint for profile server", endpt) err := http.ListenAndServe(endpt, nil) if err != nil { - logger.AppLog.Errorln("Failed to start profiling server") + logger.AppLog.Errorln("failed to start profiling server") } }() } - lvl := config.Logger.LogLevel - logger.AppLog.Infoln("Setting log level to:", lvl) + lvl, errLevel := zapcore.ParseLevel(config.Logger.LogLevel) + if errLevel != nil { + logger.AppLog.Errorln("can not parse input level") + } + logger.AppLog.Infoln("setting log level to:", lvl) logger.SetLogLevel(lvl) err := prof.InitializeAllProfiles() if err != nil { - logger.AppLog.Errorln("Failed to initialize Profiles:", err) + logger.AppLog.Errorln("failed to initialize Profiles:", err) return err } err = gnodeb.InitializeAllGnbs() if err != nil { - logger.AppLog.Errorln("Failed to initialize gNodeBs:", err) + logger.AppLog.Errorln("failed to initialize gNodeBs:", err) return err } @@ -159,7 +163,7 @@ func getCliFlags() []cli.Flag { } } -// TODO : we don't keep track of how many profiles are started... +// TODO: we don't keep track of how many profiles are started... func ListenAndLogSummary() { for intfcMsg := range profctx.SummaryChan { // TODO: do we need this event ? @@ -171,7 +175,7 @@ func ListenAndLogSummary() { // Waiting for execution summary from profile routine msg, ok := intfcMsg.(*common.SummaryMessage) if !ok { - logger.AppLog.Fatalln("Invalid Message Type") + logger.AppLog.Fatalln("invalid Message Type") } logger.AppSummaryLog.Infoln("Profile Name:", msg.ProfileName, ", Profile Type:", msg.ProfileType) diff --git a/gnodeb/context/gnbamf.go b/gnodeb/context/gnbamf.go index b2dab4d9..43ba2f92 100644 --- a/gnodeb/context/gnbamf.go +++ b/gnodeb/context/gnbamf.go @@ -11,7 +11,7 @@ import ( "github.com/omec-project/amf/factory" "github.com/omec-project/gnbsim/logger" "github.com/omec-project/openapi/models" - "github.com/sirupsen/logrus" + "go.uber.org/zap" ) const NGAP_SCTP_PORT int = 38412 @@ -25,7 +25,7 @@ type GnbAmf struct { /*Socket Connection*/ Conn net.Conn - Log *logrus.Entry + Log *zap.SugaredLogger ServedGuamiList []models.Guami PlmnSupportList []factory.PlmnSupportItem @@ -41,18 +41,12 @@ func NewGnbAmf(ip string, port int) *GnbAmf { gnbAmf := &GnbAmf{} gnbAmf.AmfIp = ip gnbAmf.AmfPort = port - gnbAmf.Log = logger.GNodeBLog.WithFields(logrus.Fields{ - "subcategory": "GnbAmf", - logger.FieldIp: gnbAmf.AmfIp, - }) + gnbAmf.Log = logger.GNodeBLog.With("subcategory", "GnbAmf", logger.FieldIp, gnbAmf.AmfIp) return gnbAmf } func (amf *GnbAmf) Init() { - amf.Log = logger.GNodeBLog.WithFields(logrus.Fields{ - "subcategory": "GnbAmf", - logger.FieldIp: amf.AmfIp, - }) + amf.Log = logger.GNodeBLog.With("subcategory", "GnbAmf", logger.FieldIp, amf.AmfIp) } func (amf *GnbAmf) GetIpAddr() string { diff --git a/gnodeb/context/gnbcpue.go b/gnodeb/context/gnbcpue.go index 96a5fe29..b6b9cce0 100644 --- a/gnodeb/context/gnbcpue.go +++ b/gnodeb/context/gnbcpue.go @@ -10,14 +10,14 @@ import ( "github.com/omec-project/gnbsim/common" "github.com/omec-project/gnbsim/logger" - "github.com/sirupsen/logrus" + "go.uber.org/zap" ) type GnbCpUe struct { Supi string Amf *GnbAmf Gnb *GNodeB - Log *logrus.Entry + Log *zap.SugaredLogger // GnbCpUe writes messages to UE on this channel WriteUeChan chan common.InterfaceMessage @@ -40,17 +40,14 @@ func NewGnbCpUe(ngapId int64, gnb *GNodeB, amf *GnbAmf) *GnbCpUe { gnbue.Amf = amf gnbue.Gnb = gnb gnbue.ReadChan = make(chan common.InterfaceMessage, 5) - gnbue.Log = logger.GNodeBLog.WithFields(logrus.Fields{ - "subcategory": "GnbCpUe", - logger.FieldGnbUeNgapId: ngapId, - }) - gnbue.Log.Traceln("Context Created") + gnbue.Log = logger.GNodeBLog.With("subcategory", "GnbCpUe", logger.FieldGnbUeNgapId, ngapId) + gnbue.Log.Debugln("context created") return &gnbue } // GetGnbUpUe returns the GnbUpUe instance corresponding to provided PDU Sess ID func (ctx *GnbCpUe) GetGnbUpUe(pduSessId int64) (*GnbUpUe, error) { - ctx.Log.Infoln("Fetching GnbUpUe for pduSessId:", pduSessId) + ctx.Log.Infoln("fetching GnbUpUe for pduSessId:", pduSessId) val, ok := ctx.GnbUpUes.Load(pduSessId) if ok { return val.(*GnbUpUe), nil @@ -61,13 +58,13 @@ func (ctx *GnbCpUe) GetGnbUpUe(pduSessId int64) (*GnbUpUe, error) { // AddGnbUpUe adds the GnbUpUe instance corresponding to provided PDU Sess ID func (ctx *GnbCpUe) AddGnbUpUe(pduSessId int64, gnbue *GnbUpUe) { - ctx.Log.Infoln("Adding new GnbUpUe for PDU Sess ID:", pduSessId) + ctx.Log.Infoln("adding new GnbUpUe for PDU Sess ID:", pduSessId) ctx.GnbUpUes.Store(pduSessId, gnbue) } // RemoveGnbUpUe removes the GnbUpUe instance corresponding to provided PDU // sess ID from the map func (ctx *GnbCpUe) RemoveGnbUpUe(pduSessId int64) { - ctx.Log.Infoln("Deleting GnbUpUe for pduSessId:", pduSessId) + ctx.Log.Infoln("deleting GnbUpUe for pduSessId:", pduSessId) ctx.GnbUpUes.Delete(pduSessId) } diff --git a/gnodeb/context/gnbpeerdao.go b/gnodeb/context/gnbpeerdao.go index d5e5246d..1646cd7f 100644 --- a/gnodeb/context/gnbpeerdao.go +++ b/gnodeb/context/gnbpeerdao.go @@ -8,13 +8,13 @@ import ( "sync" "github.com/omec-project/gnbsim/logger" - "github.com/sirupsen/logrus" + "go.uber.org/zap" ) // GnbPeerDao acts as a Data Access Object that stores and provides access to all // the GnbUpf and GnbAmf instances type GnbPeerDao struct { - Log *logrus.Entry + Log *zap.SugaredLogger // Map of UPF IP address vs GnbUpf Context. Not considering Port as they // will be same for all UPFs i.e GTP-U port 2152 @@ -27,13 +27,13 @@ type GnbPeerDao struct { func NewGnbPeerDao() *GnbPeerDao { dao := &GnbPeerDao{} - dao.Log = logger.GNodeBLog.WithFields(logrus.Fields{"subcategory": "GnbPeerDao"}) + dao.Log = logger.GNodeBLog.With("subcategory", "GnbPeerDao") return dao } // GetGnbUpf returns the GnbUpf instance corresponding to provided IP func (dao *GnbPeerDao) GetGnbUpf(ip string) *GnbUpf { - dao.Log.Infoln("Fetching GnbUpf corresponding to IP:", ip) + dao.Log.Infoln("fetching GnbUpf corresponding to IP:", ip) val, ok := dao.gnbUpfMap.Load(ip) if ok { return val.(*GnbUpf) @@ -62,6 +62,6 @@ func (dao *GnbPeerDao) GetOrAddGnbUpf(ip string) (*GnbUpf, bool) { // AddGnbUpf adds a GnbUpf instance corresponding to the IP into the map func (dao *GnbPeerDao) AddGnbUpf(ip string, gnbupf *GnbUpf) { - dao.Log.Infoln("Adding new GnbUpf corresponding to IP:", ip) + dao.Log.Infoln("adding new GnbUpf corresponding to IP:", ip) dao.gnbUpfMap.Store(ip, gnbupf) } diff --git a/gnodeb/context/gnbuedao.go b/gnodeb/context/gnbuedao.go index e73e23b9..f19a0586 100644 --- a/gnodeb/context/gnbuedao.go +++ b/gnodeb/context/gnbuedao.go @@ -8,7 +8,7 @@ import ( "sync" "github.com/omec-project/gnbsim/logger" - "github.com/sirupsen/logrus" + "go.uber.org/zap" ) // TODO: Need to separate out the DAOs @@ -16,7 +16,7 @@ import ( // GnbUeDao acts as a Data Access Object that stores and provides access to all // the GNodeB instances type GnbUeDao struct { - Log *logrus.Entry + Log *zap.SugaredLogger ngapIdGnbCpUeMap sync.Map dlTeidGnbUpUeMap sync.Map @@ -30,13 +30,13 @@ type GnbUeDao struct { func NewGnbUeDao() *GnbUeDao { dao := &GnbUeDao{} - dao.Log = logger.GNodeBLog.WithFields(logrus.Fields{"subcategory": "GnbUeDao"}) + dao.Log = logger.GNodeBLog.With("subcategory", "GnbUeDao") return dao } // GetGnbCpUe returns the GnbCpUe instance corresponding to provided NGAP ID func (dao *GnbUeDao) GetGnbCpUe(gnbUeNgapId int64) *GnbCpUe { - dao.Log.Infoln("Fetching GnbCpUe for RANUENGAPID:", gnbUeNgapId) + dao.Log.Infoln("fetching GnbCpUe for RANUENGAPID:", gnbUeNgapId) val, ok := dao.ngapIdGnbCpUeMap.Load(gnbUeNgapId) if ok { return val.(*GnbCpUe) @@ -48,13 +48,13 @@ func (dao *GnbUeDao) GetGnbCpUe(gnbUeNgapId int64) *GnbCpUe { // AddGnbCpUe adds the GnbCpUe instance corresponding to provided NGAP ID func (dao *GnbUeDao) AddGnbCpUe(gnbUeNgapId int64, gnbue *GnbCpUe) { - dao.Log.Infoln("Adding new GnbCpUe for RANUENGAPID:", gnbUeNgapId) + dao.Log.Infoln("adding new GnbCpUe for RANUENGAPID:", gnbUeNgapId) dao.ngapIdGnbCpUeMap.Store(gnbUeNgapId, gnbue) } // GetGnbUpUe returns the GnbUpUe instance corresponding to provided TEID func (dao *GnbUeDao) GetGnbUpUe(teid uint32, downlink bool) *GnbUpUe { - dao.Log.Traceln("Fetching GnbUpUe for TEID:", teid, "Downlink:", downlink) + dao.Log.Debugf("fetching GnbUpUe for TEID: %d downlink: %v", teid, downlink) var val interface{} var ok bool if downlink { @@ -71,7 +71,7 @@ func (dao *GnbUeDao) GetGnbUpUe(teid uint32, downlink bool) *GnbUpUe { // AddGnbUpUe adds the GnbUpUe instance corresponding to provided TEID func (dao *GnbUeDao) AddGnbUpUe(teid uint32, downlink bool, gnbue *GnbUpUe) { - dao.Log.Infoln("Adding new GnbUpUe for TEID:", teid, "Downlink:", downlink) + dao.Log.Infoln("adding new GnbUpUe for TEID:", teid, "Downlink:", downlink) if downlink { dao.dlTeidGnbUpUeMap.Store(teid, gnbue) } @@ -79,7 +79,7 @@ func (dao *GnbUeDao) AddGnbUpUe(teid uint32, downlink bool, gnbue *GnbUpUe) { // RemoveGnbUpUe removes the GnbUpUe instance corresponding to provided TEID func (dao *GnbUeDao) RemoveGnbUpUe(teid uint32, downlink bool) { - dao.Log.Infoln("Removing GnbUpUe for TEID:", teid, "Downlink:", downlink) + dao.Log.Infoln("removing GnbUpUe for TEID:", teid, "Downlink:", downlink) if downlink { dao.dlTeidGnbUpUeMap.Delete(teid) } diff --git a/gnodeb/context/gnbupf.go b/gnodeb/context/gnbupf.go index fda5b4f0..1675a6df 100644 --- a/gnodeb/context/gnbupf.go +++ b/gnodeb/context/gnbupf.go @@ -10,7 +10,7 @@ import ( "github.com/omec-project/gnbsim/common" "github.com/omec-project/gnbsim/logger" - "github.com/sirupsen/logrus" + "go.uber.org/zap" ) const GTP_U_PORT int = 2152 @@ -19,7 +19,7 @@ const GTP_U_PORT int = 2152 type GnbUpf struct { UpfAddr *net.UDPAddr GnbUpUes *GnbUeDao - Log *logrus.Entry + Log *zap.SugaredLogger // GnbUpf Reads messages from transport, GnbUpUe and GNodeB ReadChan chan common.InterfaceMessage @@ -30,10 +30,7 @@ type GnbUpf struct { func NewGnbUpf(ip string) *GnbUpf { gnbupf := &GnbUpf{} - gnbupf.Log = logger.GNodeBLog.WithFields(logrus.Fields{ - "subcategory": "GnbUpf", - logger.FieldIp: ip, - }) + gnbupf.Log = logger.GNodeBLog.With("subcategory", "GnbUpf", logger.FieldIp, ip) ipPort := net.JoinHostPort(ip, strconv.Itoa(GTP_U_PORT)) addr, err := net.ResolveUDPAddr("udp", ipPort) diff --git a/gnodeb/context/gnbupue.go b/gnodeb/context/gnbupue.go index 29cf8cfa..c04123f7 100644 --- a/gnodeb/context/gnbupue.go +++ b/gnodeb/context/gnbupue.go @@ -9,13 +9,13 @@ import ( "github.com/omec-project/gnbsim/logger" "github.com/omec-project/ngap/ngapType" "github.com/omec-project/openapi/models" - "github.com/sirupsen/logrus" + "go.uber.org/zap" ) type GnbUpUe struct { Upf *GnbUpf Gnb *GNodeB - Log *logrus.Entry + Log *zap.SugaredLogger PduSessType models.PduSessionType QosFlows map[int64]*ngapType.QosFlowSetupRequestItem @@ -47,26 +47,23 @@ func NewGnbUpUe(dlTeid, ulTeid uint32, gnb *GNodeB) *GnbUpUe { gnbue.ReadUlChan = make(chan common.InterfaceMessage, 10) gnbue.ReadDlChan = make(chan common.InterfaceMessage, 10) gnbue.ReadCmdChan = make(chan common.InterfaceMessage, 5) - gnbue.Log = logger.GNodeBLog.WithFields(logrus.Fields{ - "subcategory": "GnbUpUe", - logger.FieldDlTeid: dlTeid, - }) - gnbue.Log.Traceln("Context Created") + gnbue.Log = logger.GNodeBLog.With("subcategory", "GnbUpUe", logger.FieldDlTeid, dlTeid) + gnbue.Log.Debugln("context created") return &gnbue } func (ue *GnbUpUe) GetQosFlow(qfi int64) *ngapType.QosFlowSetupRequestItem { - ue.Log.Infoln("Fetching QosFlowItem corresponding to QFI:", qfi) + ue.Log.Infoln("fetching QosFlowItem corresponding to QFI:", qfi) val, ok := ue.QosFlows[qfi] if ok { return val } else { - ue.Log.Errorln("No QOS Flow found corresponding to QFI:", qfi) + ue.Log.Errorln("no QOS Flow found corresponding to QFI:", qfi) return nil } } func (ue *GnbUpUe) AddQosFlow(qfi int64, qosFlow *ngapType.QosFlowSetupRequestItem) { - ue.Log.Infoln("Adding new QosFlowItem corresponding to QFI:", qfi) + ue.Log.Infoln("adding new QosFlowItem corresponding to QFI:", qfi) ue.QosFlows[qfi] = qosFlow } diff --git a/gnodeb/context/gnodeb.go b/gnodeb/context/gnodeb.go index d5b82569..673c3802 100644 --- a/gnodeb/context/gnodeb.go +++ b/gnodeb/context/gnodeb.go @@ -8,7 +8,7 @@ import ( transport "github.com/omec-project/gnbsim/transportcommon" "github.com/omec-project/openapi/models" "github.com/omec-project/util/idgenerator" - "github.com/sirupsen/logrus" + "go.uber.org/zap" ) // GNodeB holds the context for a gNodeB. It manages the control plane and @@ -23,7 +23,7 @@ type GNodeB struct { GnbPeers *GnbPeerDao RanUeNGAPIDGenerator *idgenerator.IDGenerator DlTeidGenerator *idgenerator.IDGenerator - Log *logrus.Entry + Log *zap.SugaredLogger /*channel to notify all the go routines corresponding to this GNodeB instance to stop*/ Quit chan int diff --git a/gnodeb/gnodeb.go b/gnodeb/gnodeb.go index 0b205966..ae4b937d 100644 --- a/gnodeb/gnodeb.go +++ b/gnodeb/gnodeb.go @@ -35,8 +35,8 @@ func InitializeAllGnbs() error { // Init initializes the GNodeB struct var and connects to the default AMF func Init(gnb *gnbctx.GNodeB) error { - gnb.Log = logger.GNodeBLog.WithField(logger.FieldGnb, gnb.GnbName) - gnb.Log.Traceln("Inititializing GNodeB") + gnb.Log = logger.GNodeBLog.With(logger.FieldGnb, gnb.GnbName) + gnb.Log.Debugln("inititializing GNodeB") gnb.Log.Infoln("GNodeB IP:", gnb.GnbN2Ip, "GNodeB Port:", gnb.GnbN2Port) gnb.CpTransport = transport.NewGnbCpTransport(gnb) @@ -53,7 +53,7 @@ func Init(gnb *gnbctx.GNodeB) error { gnb.DlTeidGenerator = idgenerator.NewGenerator(int64(start), int64(end)) if gnb.DefaultAmf == nil { - gnb.Log.Infoln("Default AMF not configured, continuing ...") + gnb.Log.Infoln("default AMF not configured, continuing ...") return nil } @@ -73,12 +73,12 @@ func Init(gnb *gnbctx.GNodeB) error { go gnb.CpTransport.ReceiveFromPeer(gnb.DefaultAmf) - gnb.Log.Tracef("GNodeB Initialized %v ", gnb) + gnb.Log.Debugf("GNodeB initialized %v", gnb) return nil } func QuitGnb(gnb *gnbctx.GNodeB) { - log.Println("Shutting Down GNodeB:", gnb.GnbName) + log.Println("shutting down GNodeB:", gnb.GnbName) close(gnb.Quit) } @@ -86,7 +86,7 @@ func QuitGnb(gnb *gnbctx.GNodeB) { // It waits for the response, process the response and informs whether it was // SuccessfulOutcome or UnsuccessfulOutcome func PerformNgSetup(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf) (bool, error) { - gnb.Log.Traceln("Performing NG Setup Procedure") + gnb.Log.Debugln("performing NG Setup Procedure") var status bool @@ -97,13 +97,13 @@ func PerformNgSetup(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf) (bool, error) { return status, fmt.Errorf("failed to create ng setup request") } - gnb.Log.Traceln("Sending NG Setup Request") + gnb.Log.Debugln("sending NG Setup Request") ngSetupResp, err := gnb.CpTransport.SendToPeerBlock(amf, ngSetupReq, 0) if err != nil { gnb.Log.Errorln("SendToPeerBlock returned:", err) return status, fmt.Errorf("failed to send ng setup request") } - gnb.Log.Traceln("Received NG Setup Response") + gnb.Log.Debugln("received NG Setup Response") err = gnbamfworker.HandleMessage(gnb, amf, ngSetupResp, 0) if err != nil { gnb.Log.Errorln("HandleMessage returned:", err) diff --git a/gnodeb/transport/cptransport.go b/gnodeb/transport/cptransport.go index 58f2aa50..5aed3ae2 100644 --- a/gnodeb/transport/cptransport.go +++ b/gnodeb/transport/cptransport.go @@ -18,7 +18,7 @@ import ( "github.com/omec-project/gnbsim/stats" "github.com/omec-project/gnbsim/transportcommon" "github.com/omec-project/gnbsim/util/test" - "github.com/sirupsen/logrus" + "go.uber.org/zap" ) // Need to check if NGAP may exceed this limit @@ -30,20 +30,20 @@ var MAX_SCTP_PKT_LEN int = 2048 // GnbCpTransport represents the control plane transport of the GNodeB type GnbCpTransport struct { GnbInstance *gnbctx.GNodeB - Log *logrus.Entry + Log *zap.SugaredLogger } func NewGnbCpTransport(gnb *gnbctx.GNodeB) *GnbCpTransport { transport := &GnbCpTransport{} transport.GnbInstance = gnb - transport.Log = logger.GNodeBLog.WithFields(logrus.Fields{"subcategory": "ControlPlaneTransport"}) + transport.Log = logger.GNodeBLog.With("subcategory", "ControlPlaneTransport") return transport } // ConnectToPeer establishes SCTP connection with the AMF func (cpTprt *GnbCpTransport) ConnectToPeer(peer transportcommon.TransportPeer) (err error) { - cpTprt.Log.Traceln("Connecting to AMF") + cpTprt.Log.Debugln("connecting to AMF") amf := peer.(*gnbctx.GnbAmf) gnb := cpTprt.GnbInstance @@ -67,7 +67,7 @@ func (cpTprt *GnbCpTransport) ConnectToPeer(peer transportcommon.TransportPeer) amf.AmfIp, amf.AmfPort, err) } - cpTprt.Log.Infoln("Connected to AMF, AMF IP:", amf.AmfIp, "AMF Port:", amf.AmfPort) + cpTprt.Log.Infoln("connected to AMF, AMF IP:", amf.AmfIp, "AMF Port:", amf.AmfPort) return } @@ -95,7 +95,7 @@ func (cpTprt *GnbCpTransport) SendToPeerBlock(peer transportcommon.TransportPeer return nil, fmt.Errorf("failed to read from socket") } - cpTprt.Log.Infof("Read %v bytes from %v\n", n, conn.RemoteAddr()) + cpTprt.Log.Infof("read %v bytes from %v", n, conn.RemoteAddr()) return recvMsg[:n], nil } @@ -114,7 +114,7 @@ func (cpTprt *GnbCpTransport) SendToPeer(peer transportcommon.TransportPeer, defer func() { recerr := recover() if recerr != nil { - cpTprt.Log.Errorln("Recovered panic in SendToPeer, error:", recerr) + cpTprt.Log.Errorln("recovered panic in SendToPeer, error:", recerr) err = fmt.Errorf("recovered panic") } }() @@ -123,10 +123,10 @@ func (cpTprt *GnbCpTransport) SendToPeer(peer transportcommon.TransportPeer, m := &stats.StatisticsEvent{EType: stats.MSG_OUT, Id: id, T: t} stats.SentMessage(m) if n, err := amf.Conn.Write(pkt); err != nil || n != len(pkt) { - cpTprt.Log.Errorln("Write returned:", err) + cpTprt.Log.Errorln("write returned:", err) return fmt.Errorf("failed to write on socket") } else { - cpTprt.Log.Infof("Wrote %v bytes\n", n) + cpTprt.Log.Infof("wrote %v bytes", n) } return @@ -139,7 +139,7 @@ func (cpTprt *GnbCpTransport) ReceiveFromPeer(peer transportcommon.TransportPeer defer func() { if err := amf.Conn.Close(); err != nil && err != syscall.EBADF { - cpTprt.Log.Errorln("Close returned:", err) + cpTprt.Log.Errorln("close returned:", err) } }() @@ -151,16 +151,16 @@ func (cpTprt *GnbCpTransport) ReceiveFromPeer(peer transportcommon.TransportPeer if err != nil { switch err { case io.EOF, io.ErrUnexpectedEOF: - cpTprt.Log.Errorln("Read EOF from client") + cpTprt.Log.Errorln("read EOF from client") return case syscall.EAGAIN: cpTprt.Log.Warnln("SCTP read timeout") continue case syscall.EINTR: - cpTprt.Log.Warnf("SCTPRead: %+v\n", err) + cpTprt.Log.Warnf("SCTPRead: %+v", err) continue default: - cpTprt.Log.Errorf("Handle connection[addr: %+v] error: %+v\n", amf.Conn.RemoteAddr(), err) + cpTprt.Log.Errorf("handle connection[addr: %+v] error: %+v", amf.Conn.RemoteAddr(), err) return } } @@ -169,7 +169,7 @@ func (cpTprt *GnbCpTransport) ReceiveFromPeer(peer transportcommon.TransportPeer m := &stats.StatisticsEvent{EType: stats.MSG_IN, Id: id, T: t} stats.RecvdMessage(m) - cpTprt.Log.Infof("Read %v bytes from %v\n", n, amf.GetIpAddr()) + cpTprt.Log.Infof("read %v bytes from %v", n, amf.GetIpAddr()) // TODO Post to gnbamfworker channel err = gnbamfworker.HandleMessage(cpTprt.GnbInstance, amf, recvMsg[:n], id) diff --git a/gnodeb/transport/uptransport.go b/gnodeb/transport/uptransport.go index 916c52e4..2e8f9610 100644 --- a/gnodeb/transport/uptransport.go +++ b/gnodeb/transport/uptransport.go @@ -13,7 +13,7 @@ import ( gnbctx "github.com/omec-project/gnbsim/gnodeb/context" "github.com/omec-project/gnbsim/logger" "github.com/omec-project/gnbsim/transportcommon" - "github.com/sirupsen/logrus" + "go.uber.org/zap" ) // Need to check if NGAP may exceed this limit @@ -29,13 +29,13 @@ type GnbUpTransport struct { /* UDP Connection without any association with peers */ Conn *net.UDPConn - Log *logrus.Entry + Log *zap.SugaredLogger } func NewGnbUpTransport(gnb *gnbctx.GNodeB) *GnbUpTransport { transport := &GnbUpTransport{} transport.GnbInstance = gnb - transport.Log = logger.GNodeBLog.WithFields(logrus.Fields{"subcategory": "UserPlaneTransport"}) + transport.Log = logger.GNodeBLog.With("subcategory", "UserPlaneTransport") return transport } @@ -80,7 +80,7 @@ func (upTprt *GnbUpTransport) SendToPeer(peer transportcommon.TransportPeer, } else if n != pktLen { return fmt.Errorf("total bytes:%v, written bytes:%v", pktLen, n) } else { - upTprt.Log.Infof("Sent UDP Packet, length: %v bytes\n", n) + upTprt.Log.Infof("sent UDP Packet, length: %v bytes", n) } return @@ -97,17 +97,17 @@ func (upTprt *GnbUpTransport) ReceiveFromPeer(peer transportcommon.TransportPeer upTprt.Log.Errorln("ReadFromUDP returned:", err) } srcIp := srcAddr.IP.String() - upTprt.Log.Infof("Read %v bytes from %v:%v\n", n, srcIp, srcAddr.Port) + upTprt.Log.Infof("read %v bytes from %v:%v", n, srcIp, srcAddr.Port) gnbupf := upTprt.GnbInstance.GnbPeers.GetGnbUpf(srcIp) if gnbupf == nil { - upTprt.Log.Errorln("No UPF Context found corresponding to IP:", srcIp) + upTprt.Log.Errorln("no UPF Context found corresponding to IP:", srcIp) continue } tMsg := &common.TransportMessage{} tMsg.RawPkt = recvMsg[:n] gnbupf.ReadChan <- tMsg - upTprt.Log.Traceln("Forwarded UDP packet to UPF Worker") + upTprt.Log.Debugln("forwarded UDP packet to UPF Worker") } } diff --git a/gnodeb/worker/gnbamfworker/handler.go b/gnodeb/worker/gnbamfworker/handler.go index 91639ada..fb7ee95e 100644 --- a/gnodeb/worker/gnbamfworker/handler.go +++ b/gnodeb/worker/gnbamfworker/handler.go @@ -23,7 +23,7 @@ func HandleNgSetupResponse(amf *gnbctx.GnbAmf, pdu *ngapType.NGAPPDU) { amf.Log.Errorln("ran is nil") return } - amf.Log.Traceln("Processing NG Setup Response") + amf.Log.Debugln("processing NG Setup Response") var amfName *ngapType.AMFName var servedGUAMIList *ngapType.ServedGUAMIList var relativeAMFCapacity *ngapType.RelativeAMFCapacity @@ -36,7 +36,7 @@ func HandleNgSetupResponse(amf *gnbctx.GnbAmf, pdu *ngapType.NGAPPDU) { } successfulOutcome := pdu.SuccessfulOutcome if successfulOutcome == nil { - amf.Log.Errorln("Initiating Message is nil") + amf.Log.Errorln("InitiatingMessage is nil") return } ngSetupResponse := successfulOutcome.Value.NGSetupResponse @@ -45,34 +45,34 @@ func HandleNgSetupResponse(amf *gnbctx.GnbAmf, pdu *ngapType.NGAPPDU) { return } - amf.Log.Traceln("Handle NG Setup response") + amf.Log.Debugln("handle NG Setup response") for i := 0; i < len(ngSetupResponse.ProtocolIEs.List); i++ { ie := ngSetupResponse.ProtocolIEs.List[i] switch ie.Id.Value { case ngapType.ProtocolIEIDAMFName: amfName = ie.Value.AMFName - amf.Log.Traceln("Decode IE AMFName") + amf.Log.Debugln("decode IE AMFName") if amfName == nil { amf.Log.Errorln("AMFName is nil") return } case ngapType.ProtocolIEIDServedGUAMIList: servedGUAMIList = ie.Value.ServedGUAMIList - amf.Log.Traceln("Decode IE ServedGUAMIList") + amf.Log.Debugln("decode IE ServedGUAMIList") if servedGUAMIList == nil { amf.Log.Errorln("ServedGUAMIList is nil") return } case ngapType.ProtocolIEIDRelativeAMFCapacity: relativeAMFCapacity = ie.Value.RelativeAMFCapacity - amf.Log.Traceln("Decode IE RelativeAMFCapacity") + amf.Log.Debugln("decode IE RelativeAMFCapacity") if relativeAMFCapacity == nil { amf.Log.Errorln("RelativeAMFCapacity is nil") return } case ngapType.ProtocolIEIDPLMNSupportList: plmnSupportList = ie.Value.PLMNSupportList - amf.Log.Traceln("Decode IE PLMNSupportList") + amf.Log.Debugln("decode IE PLMNSupportList") if plmnSupportList == nil { amf.Log.Errorln("PLMNSupportList is nil") return @@ -113,7 +113,7 @@ func HandleNgSetupResponse(amf *gnbctx.GnbAmf, pdu *ngapType.NGAPPDU) { } if len(amf.ServedGuamiList) == 0 { - amf.Log.Errorln("NG Setup Response : Empty ServedGuamiList received") + amf.Log.Errorln("NG Setup Response: Empty ServedGuamiList received") } /* else { // TODO: Need to check }*/ @@ -147,14 +147,14 @@ func HandleNgSetupResponse(amf *gnbctx.GnbAmf, pdu *ngapType.NGAPPDU) { } if len(amf.PlmnSupportList) == 0 { - amf.Log.Errorln("NG Setup Response : Empty PLMNSupportList received") + amf.Log.Errorln("NG Setup Response: Empty PLMNSupportList received") } /*else { // TODO: Need to check whether it should be compared against some // existing list within gNodeB }*/ amf.SetNgSetupStatus(true) - amf.Log.Traceln("Processed NG Setup Response") + amf.Log.Debugln("processed NG Setup Response") } func HandleNgSetupFailure(amf *gnbctx.GnbAmf, pdu *ngapType.NGAPPDU) { @@ -163,7 +163,7 @@ func HandleNgSetupFailure(amf *gnbctx.GnbAmf, pdu *ngapType.NGAPPDU) { amf.Log.Errorln("ran is nil") return } - amf.Log.Traceln("Processing NG Setup Failure") + amf.Log.Debugln("processing NG Setup Failure") var cause *ngapType.Cause if pdu == nil { @@ -181,12 +181,12 @@ func HandleNgSetupFailure(amf *gnbctx.GnbAmf, pdu *ngapType.NGAPPDU) { return } - amf.Log.Traceln("Handle NG Setup Failure") + amf.Log.Debugln("handle NG Setup Failure") for i := 0; i < len(ngSetupFailure.ProtocolIEs.List); i++ { ie := ngSetupFailure.ProtocolIEs.List[i] if ie.Id.Value == ngapType.ProtocolIEIDCause { cause = ie.Value.Cause - amf.Log.Traceln("Decode IE Cause") + amf.Log.Debugln("decode IE Cause") if cause == nil { amf.Log.Errorln("Cause is nil") return @@ -199,7 +199,7 @@ func HandleNgSetupFailure(amf *gnbctx.GnbAmf, pdu *ngapType.NGAPPDU) { test.PrintAndGetCause(cause) amf.SetNgSetupStatus(false) - amf.Log.Traceln("Processed NG Setup Failure") + amf.Log.Debugln("processed NG Setup Failure") } func HandleDownlinkNasTransport(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf, @@ -210,7 +210,7 @@ func HandleDownlinkNasTransport(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf, amf.Log.Errorln("ran is nil") return } - amf.Log.Traceln("Processing Downlink Nas Transport") + amf.Log.Debugln("processing Downlink Nas Transport") var gnbUeNgapId *ngapType.RANUENGAPID if pdu == nil { @@ -232,12 +232,12 @@ func HandleDownlinkNasTransport(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf, return } - amf.Log.Traceln("Handle Downlink NAS Transport") + amf.Log.Debugln("handle Downlink NAS Transport") for i := 0; i < len(downlinkNasTransport.ProtocolIEs.List); i++ { ie := downlinkNasTransport.ProtocolIEs.List[i] if ie.Id.Value == ngapType.ProtocolIEIDRANUENGAPID { gnbUeNgapId = ie.Value.RANUENGAPID - amf.Log.Traceln("Decode IE RANUENGAPID") + amf.Log.Debugln("decode IE RANUENGAPID") if gnbUeNgapId == nil { amf.Log.Errorln("RANUENGAPID is nil") return @@ -248,7 +248,7 @@ func HandleDownlinkNasTransport(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf, ngapId := gnbUeNgapId.Value gnbue := gnb.GnbUes.GetGnbCpUe(ngapId) if gnbue == nil { - amf.Log.Errorln("No GnbUe found corresponding to RANUENGAPID:", ngapId) + amf.Log.Errorln("no GnbUe found corresponding to RANUENGAPID:", ngapId) return } @@ -263,7 +263,7 @@ func HandleInitialContextSetupRequest(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf, amf.Log.Errorln("ran is nil") return } - amf.Log.Traceln("Processing Initial Context Setup Request") + amf.Log.Debugln("processing Initial Context Setup Request") var gnbUeNgapId *ngapType.RANUENGAPID if pdu == nil { @@ -276,7 +276,7 @@ func HandleInitialContextSetupRequest(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf, } initiatingMessage := pdu.InitiatingMessage if initiatingMessage == nil { - amf.Log.Errorln("Initiating Message is nil") + amf.Log.Errorln("InitiatingMessage is nil") return } initialContextSetupRequest := initiatingMessage.Value.InitialContextSetupRequest @@ -285,11 +285,11 @@ func HandleInitialContextSetupRequest(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf, return } - amf.Log.Traceln("InitialContextSetupRequest") + amf.Log.Debugln("InitialContextSetupRequest") for _, ie := range initialContextSetupRequest.ProtocolIEs.List { if ie.Id.Value == ngapType.ProtocolIEIDRANUENGAPID { gnbUeNgapId = ie.Value.RANUENGAPID - amf.Log.Traceln("Decode IE RANUENGAPID") + amf.Log.Debugln("decode IE RANUENGAPID") if gnbUeNgapId == nil { amf.Log.Errorln("RANUENGAPID is nil") return @@ -300,7 +300,7 @@ func HandleInitialContextSetupRequest(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf, ngapId := gnbUeNgapId.Value gnbue := gnb.GnbUes.GetGnbCpUe(ngapId) if gnbue == nil { - amf.Log.Errorln("No GnbUe found corresponding to RANUENGAPID:") + amf.Log.Errorln("no GnbUe found corresponding to RANUENGAPID:") return } @@ -316,7 +316,7 @@ func HandlePduSessResourceSetupRequest(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf, amf.Log.Errorln("ran is nil") return } - amf.Log.Traceln("Processing Pdu Session Resource Setup Request") + amf.Log.Debugln("processing Pdu Session Resource Setup Request") var gnbUeNgapId *ngapType.RANUENGAPID if pdu == nil { @@ -329,7 +329,7 @@ func HandlePduSessResourceSetupRequest(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf, } initiatingMessage := pdu.InitiatingMessage if initiatingMessage == nil { - amf.Log.Errorln("Initiating Message is nil") + amf.Log.Errorln("InitiatingMessage is nil") return } pduSessResourceSetupReq := initiatingMessage.Value.PDUSessionResourceSetupRequest @@ -341,7 +341,7 @@ func HandlePduSessResourceSetupRequest(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf, for _, ie := range pduSessResourceSetupReq.ProtocolIEs.List { if ie.Id.Value == ngapType.ProtocolIEIDRANUENGAPID { gnbUeNgapId = ie.Value.RANUENGAPID - amf.Log.Traceln("Decode IE RANUENGAPID") + amf.Log.Debugln("decode IE RANUENGAPID") if gnbUeNgapId == nil { amf.Log.Errorln("RANUENGAPID is nil") return @@ -352,7 +352,7 @@ func HandlePduSessResourceSetupRequest(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf, ngapId := gnbUeNgapId.Value gnbue := gnb.GnbUes.GetGnbCpUe(ngapId) if gnbue == nil { - amf.Log.Errorln("No GnbUe found corresponding to RANUENGAPID:") + amf.Log.Errorln("no GnbUe found corresponding to RANUENGAPID:") return } @@ -367,7 +367,7 @@ func HandlePduSessResourceReleaseCommand(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf, amf.Log.Errorln("ran is nil") return } - amf.Log.Traceln("Processing Pdu Session Resource Release Command") + amf.Log.Debugln("processing Pdu Session Resource Release Command") var gnbUeNgapId *ngapType.RANUENGAPID if pdu == nil { @@ -380,7 +380,7 @@ func HandlePduSessResourceReleaseCommand(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf, } initiatingMessage := pdu.InitiatingMessage if initiatingMessage == nil { - amf.Log.Errorln("Initiating Message is nil") + amf.Log.Errorln("InitiatingMessage is nil") return } pduSessResourceReleaseCmd := initiatingMessage.Value.PDUSessionResourceReleaseCommand @@ -392,7 +392,7 @@ func HandlePduSessResourceReleaseCommand(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf, for _, ie := range pduSessResourceReleaseCmd.ProtocolIEs.List { if ie.Id.Value == ngapType.ProtocolIEIDRANUENGAPID { gnbUeNgapId = ie.Value.RANUENGAPID - amf.Log.Traceln("Decode IE RANUENGAPID") + amf.Log.Debugln("decode IE RANUENGAPID") if gnbUeNgapId == nil { amf.Log.Errorln("RANUENGAPID is nil") return @@ -403,7 +403,7 @@ func HandlePduSessResourceReleaseCommand(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf, ngapId := gnbUeNgapId.Value gnbue := gnb.GnbUes.GetGnbCpUe(ngapId) if gnbue == nil { - amf.Log.Errorln("No GnbUe found corresponding to RANUENGAPID:") + amf.Log.Errorln("no GnbUe found corresponding to RANUENGAPID:") return } @@ -419,7 +419,7 @@ func HandleUeCtxReleaseCommand(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf, return } - amf.Log.Traceln("Processing Ue Context Release Command") + amf.Log.Debugln("processing Ue Context Release Command") if pdu == nil { amf.Log.Errorln("NGAP Message is nil") @@ -434,7 +434,7 @@ func HandleUeCtxReleaseCommand(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf, initiatingMessage := pdu.InitiatingMessage if initiatingMessage == nil { - amf.Log.Errorln("Initiating Message is nil") + amf.Log.Errorln("InitiatingMessage is nil") return } @@ -462,14 +462,14 @@ func HandleUeCtxReleaseCommand(gnb *gnbctx.GNodeB, amf *gnbctx.GnbAmf, } } else { /*TODO: Should add mapping for AMFUENGAPID vs GnbCpUeContext*/ - amf.Log.Errorln("No RANUENGAPID received") + amf.Log.Errorln("no RANUENGAPID received") return } ngapId := ueNgapIds.UENGAPIDPair.RANUENGAPID.Value gnbue := gnb.GnbUes.GetGnbCpUe(ngapId) if gnbue == nil { - amf.Log.Errorln("No GnbUe found corresponding to RANUENGAPID:", ngapId) + amf.Log.Errorln("no GnbUe found corresponding to RANUENGAPID:", ngapId) return } diff --git a/gnodeb/worker/gnbcpueworker/handler.go b/gnodeb/worker/gnbcpueworker/handler.go index 580a3cab..262e53e2 100644 --- a/gnodeb/worker/gnbcpueworker/handler.go +++ b/gnodeb/worker/gnbcpueworker/handler.go @@ -6,7 +6,6 @@ package gnbcpueworker import ( "encoding/binary" - "fmt" "sync" "time" @@ -53,7 +52,7 @@ func HandleInitialUEMessage(gnbue *gnbctx.GnbCpUe, gnbue.Log.Errorln("SendToPeer failed:", err) return } - gnbue.Log.Traceln("Sent Uplink NAS Message to AMF") + gnbue.Log.Debugln("sent Uplink NAS Message to AMF") } else { sendMsg, err := ngap.GetInitialUEMessage(gnbue, msg.NasPdus[0], msg.Tmsi) if err != nil { @@ -65,7 +64,7 @@ func HandleInitialUEMessage(gnbue *gnbctx.GnbCpUe, gnbue.Log.Errorln("SendToPeer failed:", err) return } - gnbue.Log.Traceln("Sent Initial UE Message to AMF") + gnbue.Log.Debugln("sent Initial UE Message to AMF") } } @@ -112,7 +111,7 @@ func HandleUlInfoTransfer(gnbue *gnbctx.GnbCpUe, intfcMsg common.InterfaceMessage, ) { msg := intfcMsg.(*common.UuMessage) - gnbue.Log.Traceln("Creating Uplink NAS Transport Message") + gnbue.Log.Debugln("creating Uplink NAS Transport Message") sendMsg, err := ngap.GetUplinkNASTransport(gnbue, msg.NasPdus[0]) if err != nil { gnbue.Log.Errorln("GetUplinkNASTransport failed:", err) @@ -124,7 +123,7 @@ func HandleUlInfoTransfer(gnbue *gnbctx.GnbCpUe, return } - gnbue.Log.Traceln("Sent Uplink NAS Transport Message to AMF") + gnbue.Log.Debugln("sent Uplink NAS Transport Message to AMF") } func HandleInitialContextSetupRequest(gnbue *gnbctx.GnbCpUe, @@ -168,7 +167,7 @@ func HandleInitialContextSetupRequest(gnbue *gnbctx.GnbCpUe, var pdus common.NasPduList pdus = append(pdus, nasPdu.Value) SendToUe(gnbue, common.DL_INFO_TRANSFER_EVENT, pdus, msg.Id) - gnbue.Log.Traceln("Sent DL Information Transfer Event to UE") + gnbue.Log.Debugln("sent DL Information Transfer Event to UE") } var list []pduSessResourceSetupItem @@ -195,7 +194,7 @@ func HandleInitialContextSetupRequest(gnbue *gnbctx.GnbCpUe, resp, err := test.GetInitialContextSetupResponse(gnbue.AmfUeNgapId, gnbue.GnbUeNgapId) if err != nil { - gnbue.Log.Errorln("Failed to create Initial Context Setup Response Message ") + gnbue.Log.Errorln("failed to create Initial Context Setup Response Message") return } @@ -303,7 +302,7 @@ func HandlePduSessResourceReleaseCommand(gnbue *gnbctx.GnbCpUe, upCtx, err := gnbue.GetGnbUpUe(pduSessId) if err != nil { - gnbue.Log.Errorln("Failed to fetch PDU session context:", err) + gnbue.Log.Errorln("failed to fetch PDU session context:", err) return } terminateUpUeContext(upCtx) @@ -314,13 +313,13 @@ func HandlePduSessResourceReleaseCommand(gnbue *gnbctx.GnbCpUe, var pdus common.NasPduList pdus = append(pdus, nasPdu.Value) SendToUe(gnbue, common.DL_INFO_TRANSFER_EVENT, pdus, msg.Id) - gnbue.Log.Traceln("Sent DL Information Transfer Event to UE") + gnbue.Log.Debugln("sent DL Information Transfer Event to UE") } ngapPdu, err := test.GetPDUSessionResourceReleaseResponse(gnbue.AmfUeNgapId, gnbue.GnbUeNgapId) if err != nil { - gnbue.Log.Errorln("Failed to create PDU Session Resource Release Response:", err) + gnbue.Log.Errorln("failed to create PDU Session Resource Release Response:", err) return } @@ -329,7 +328,7 @@ func HandlePduSessResourceReleaseCommand(gnbue *gnbctx.GnbCpUe, gnbue.Log.Errorln("SendToPeer failed:", err) return } - gnbue.Log.Traceln("Sent PDU Session Resource Setup Response Message to AMF") + gnbue.Log.Debugln("sent PDU Session Resource Setup Response Message to AMF") SendToUe(gnbue, common.DATA_BEARER_RELEASE_REQUEST_EVENT, nil, msg.Id) } @@ -346,7 +345,7 @@ func HandleDataBearerSetupResponse(gnbue *gnbctx.GnbCpUe, } else { gnbUpUe, err := gnbue.GetGnbUpUe(pduSess.PduSessId) if err != nil { - gnbue.Log.Errorln("Failed to fetch PDU session context:", err) + gnbue.Log.Errorln("failed to fetch PDU session context:", err) } // TODO: Addition to this map should only be through GnbUpfWorker // routine. This will help in replacing sync map with normal map @@ -369,14 +368,14 @@ func HandleDataBearerSetupResponse(gnbue *gnbctx.GnbCpUe, ngapPdu, err = test.GetPDUSessionResourceSetupResponse(pduSessions, gnbue.AmfUeNgapId, gnbue.GnbUeNgapId, gnbue.Gnb.GnbN3Ip) if err != nil { - gnbue.Log.Errorln("Failed to create PDU Session Resource Setup Response:", err) + gnbue.Log.Errorln("failed to create PDU Session Resource Setup Response:", err) return } } else if msg.TriggeringEvent == common.INITIAL_CTX_SETUP_REQUEST_EVENT { ngapPdu, err = test.GetInitialContextSetupResponseForServiceRequest(pduSessions, gnbue.AmfUeNgapId, gnbue.GnbUeNgapId, gnbue.Gnb.GnbN3Ip) if err != nil { - gnbue.Log.Errorln("Failed to create Initial Context Setup Response:", err) + gnbue.Log.Errorln("failed to create Initial Context Setup Response:", err) return } } @@ -386,7 +385,7 @@ func HandleDataBearerSetupResponse(gnbue *gnbctx.GnbCpUe, gnbue.Log.Errorln("SendToPeer failed:", err) return } - gnbue.Log.Traceln("Sent PDU Session Resource Setup Response Message to AMF") + gnbue.Log.Debugln("sent PDU Session Resource Setup Response Message to AMF") } func HandleUeCtxReleaseCommand(gnbue *gnbctx.GnbCpUe, @@ -430,7 +429,7 @@ func HandleUeCtxReleaseCommand(gnbue *gnbctx.GnbCpUe, ngapPdu, err := ngap.GetUEContextReleaseComplete(gnbue) if err != nil { - fmt.Println("Failed to create UE Context Release Complete message") + gnbue.Log.Errorln("failed to create UE Context Release Complete message") return } @@ -442,7 +441,7 @@ func HandleUeCtxReleaseCommand(gnbue *gnbctx.GnbCpUe, gnbue.Log.Errorln("SendToPeer failed:", err) return } - gnbue.Log.Traceln("Sent UE Context Release Complete Message to AMF") + gnbue.Log.Debugln("sent UE Context Release Complete Message to AMF") quitEvt := &common.DefaultMessage{} quitEvt.Event = common.QUIT_EVENT @@ -464,9 +463,9 @@ func HandleRanConnectionRelease(gnbue *gnbctx.GnbCpUe, ) { // Todo: The cause for the RAN connection release should be sent by the // Sim-UE, which should receive it through configuration - gnbue.Log.Traceln("Handling RAN Connection Release Event") + gnbue.Log.Debugln("handling RAN Connection Release Event") - gnbue.Log.Traceln("Creating UE Context Release Request") + gnbue.Log.Debugln("creating UE Context Release Request") sendMsg, err := ngap.GetUEContextReleaseRequest(gnbue) if err != nil { @@ -484,7 +483,7 @@ func HandleRanConnectionRelease(gnbue *gnbctx.GnbCpUe, return } - gnbue.Log.Traceln("Sent Uplink NAS Transport Message to AMF") + gnbue.Log.Debugln("sent Uplink NAS Transport Message to AMF") } func ProcessPduSessResourceSetupList(gnbue *gnbctx.GnbCpUe, @@ -602,7 +601,7 @@ func ProcessPduSessResourceSetupList(gnbue *gnbctx.GnbCpUe, if len(nasPdus) != 0 { SendToUe(gnbue, common.DL_INFO_TRANSFER_EVENT, nasPdus, id) - gnbue.Log.Traceln("Sent DL Information Transfer Event to UE") + gnbue.Log.Debugln("sent DL Information Transfer Event to UE") } /* TODO: To be fixed, currently Data Bearer Setup Event may get processed diff --git a/gnodeb/worker/gnbcpueworker/worker.go b/gnodeb/worker/gnbcpueworker/worker.go index 47713a51..d63caf88 100644 --- a/gnodeb/worker/gnbcpueworker/worker.go +++ b/gnodeb/worker/gnbcpueworker/worker.go @@ -45,7 +45,7 @@ func HandleEvents(gnbue *gnbctx.GnbCpUe) (err error) { case common.QUIT_EVENT: HandleQuitEvent(gnbue, msg) default: - gnbue.Log.Infoln("Event", evt, "is not supported") + gnbue.Log.Infoln("event", evt, "is not supported") } // TODO: Need to return and handle errors from handlers @@ -54,7 +54,7 @@ func HandleEvents(gnbue *gnbctx.GnbCpUe) (err error) { } func SendToUe(gnbue *gnbctx.GnbCpUe, event common.EventType, nasPdus common.NasPduList, id uint64) { - gnbue.Log.Traceln("Sending event", event, "to SimUe. Id:", id) + gnbue.Log.Debugln("sending event", event, "to SimUe. Id:", id) uemsg := common.UuMessage{} uemsg.Id = id uemsg.Event = event diff --git a/gnodeb/worker/gnbupfworker/handler.go b/gnodeb/worker/gnbupfworker/handler.go index 031609da..f1768a16 100644 --- a/gnodeb/worker/gnbupfworker/handler.go +++ b/gnodeb/worker/gnbupfworker/handler.go @@ -14,7 +14,7 @@ import ( * context */ func HandleDlGpduMessage(gnbUpf *gnbctx.GnbUpf, gtpPdu *test.GtpPdu) error { - gnbUpf.Log.Traceln("Processing downlink G-PDU packet") + gnbUpf.Log.Debugln("processing downlink G-PDU packet") gnbUpUe := gnbUpf.GnbUpUes.GetGnbUpUe(gtpPdu.Hdr.Teid, true) if gnbUpUe == nil { return nil diff --git a/gnodeb/worker/gnbupfworker/worker.go b/gnodeb/worker/gnbupfworker/worker.go index 179ececb..fd40ca2d 100644 --- a/gnodeb/worker/gnbupfworker/worker.go +++ b/gnodeb/worker/gnbupfworker/worker.go @@ -54,7 +54,7 @@ func HandleMessage(gnbUpf *gnbctx.GnbUpf, msg common.InterfaceMessage) error { } func SendToGnbUe(gnbue *gnbctx.GnbCpUe, event common.EventType, ngapPdu *ngapType.NGAPPDU) { - gnbue.Log.Traceln("Sending:", event) + gnbue.Log.Debugln("sending:", event) amfmsg := common.N2Message{} amfmsg.Event = event amfmsg.NgapPdu = ngapPdu diff --git a/gnodeb/worker/gnbupueworker/handler.go b/gnodeb/worker/gnbupueworker/handler.go index 2388b69d..cf446f16 100644 --- a/gnodeb/worker/gnbupueworker/handler.go +++ b/gnodeb/worker/gnbupueworker/handler.go @@ -13,7 +13,7 @@ import ( ) func HandleUlMessage(gnbue *gnbctx.GnbUpUe, msg common.InterfaceMessage) (err error) { - gnbue.Log.Traceln("Handling UL Packet from UE") + gnbue.Log.Debugln("handling UL Packet from UE") if msg.GetEventType() == common.LAST_DATA_PKT_EVENT { gnbue.Log.Debugln("Received last uplink data packet") @@ -37,12 +37,12 @@ func HandleUlMessage(gnbue *gnbctx.GnbUpUe, msg common.InterfaceMessage) (err er gnbue.Log.Errorln("UP Transport SendToPeer() returned:", err) return fmt.Errorf("failed to send gpdu") } - gnbue.Log.Traceln("Sent UL Packet from UE to UPF") + gnbue.Log.Debugln("sent UL Packet from UE to UPF") return nil } func HandleDlMessage(gnbue *gnbctx.GnbUpUe, intfcMsg common.InterfaceMessage) (err error) { - gnbue.Log.Traceln("Handling DL Packet from UPF Worker") + gnbue.Log.Debugln("handling DL Packet from UPF Worker") msg := intfcMsg.(*common.N3Message) if len(msg.Pdu.Payload) == 0 { @@ -65,13 +65,13 @@ func HandleDlMessage(gnbue *gnbctx.GnbUpUe, intfcMsg common.InterfaceMessage) (e } ueDataMsg.Qfi = new(uint8) *ueDataMsg.Qfi = extHdr.Qfi - gnbue.Log.Infoln("Received QFI value in downlink G-PDU:", extHdr.Qfi) + gnbue.Log.Infoln("received QFI value in downlink G-PDU:", extHdr.Qfi) } } ueDataMsg.Event = common.DL_UE_DATA_TRANSFER_EVENT gnbue.WriteUeChan <- ueDataMsg - gnbue.Log.Infoln("Sent DL user data packet to UE") + gnbue.Log.Infoln("sent DL user data packet to UE") return nil } @@ -88,7 +88,7 @@ func HandleQuitEvent(gnbue *gnbctx.GnbUpUe, intfcMsg common.InterfaceMessage) (e if !gnbue.LastDataPktRecvd { for pkt := range gnbue.ReadUlChan { if pkt.GetEventType() == common.LAST_DATA_PKT_EVENT { - gnbue.Log.Debugln("Received last uplink data packet") + gnbue.Log.Debugln("received last uplink data packet") break } } diff --git a/go.mod b/go.mod index 7db2d6d1..1e7284f2 100644 --- a/go.mod +++ b/go.mod @@ -4,20 +4,18 @@ go 1.21 require ( git.cs.nctu.edu.tw/calee/sctp v1.1.0 - github.com/antonfisher/nested-logrus-formatter v1.3.1 github.com/calee0219/fatal v0.0.1 github.com/gin-contrib/cors v1.7.2 github.com/gin-gonic/gin v1.10.0 - github.com/omec-project/amf v1.4.5 + github.com/omec-project/amf v1.5.0 github.com/omec-project/aper v1.2.1 - github.com/omec-project/nas v1.3.0 + github.com/omec-project/nas v1.4.1 github.com/omec-project/ngap v1.3.0 github.com/omec-project/openapi v1.3.1 - github.com/omec-project/util v1.1.0 - github.com/sirupsen/logrus v1.9.3 - github.com/stretchr/testify v1.9.0 + github.com/omec-project/util v1.2.1 github.com/urfave/cli v1.22.15 github.com/yerden/go-util v1.1.4 + go.uber.org/zap v1.27.0 golang.org/x/net v0.29.0 golang.org/x/sys v0.25.0 gopkg.in/yaml.v2 v2.4.0 @@ -36,7 +34,6 @@ require ( github.com/coreos/go-semver v0.3.0 // indirect github.com/coreos/go-systemd/v22 v22.3.2 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect - github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/evanphx/json-patch v5.9.0+incompatible // indirect github.com/gabriel-vasile/mimetype v1.4.3 // indirect @@ -62,14 +59,12 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect - github.com/montanaflynn/stats v0.6.6 // indirect + github.com/montanaflynn/stats v0.7.1 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/omec-project/metricfunc v1.4.1 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/pierrec/lz4/v4 v4.1.15 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.20.3 // indirect + github.com/prometheus/client_golang v1.20.4 // indirect github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/common v0.55.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect @@ -81,14 +76,13 @@ require ( github.com/xdg-go/pbkdf2 v1.0.0 // indirect github.com/xdg-go/scram v1.1.2 // indirect github.com/xdg-go/stringprep v1.0.4 // indirect - github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect + github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect go.etcd.io/etcd/api/v3 v3.5.12 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.12 // indirect go.etcd.io/etcd/client/v3 v3.5.12 // indirect - go.mongodb.org/mongo-driver v1.11.7 // indirect + go.mongodb.org/mongo-driver v1.17.0 // indirect go.opencensus.io v0.24.0 // indirect go.uber.org/multierr v1.10.0 // indirect - go.uber.org/zap v1.27.0 // indirect go4.org/intern v0.0.0-20220617035311-6925f38cc365 // indirect go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2 // indirect golang.org/x/arch v0.8.0 // indirect @@ -96,9 +90,9 @@ require ( golang.org/x/oauth2 v0.23.0 // indirect golang.org/x/sync v0.8.0 // indirect golang.org/x/text v0.18.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect - google.golang.org/grpc v1.66.2 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect + google.golang.org/grpc v1.67.0 // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/h2non/gock.v1 v1.1.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 03298d9b..65959428 100644 --- a/go.sum +++ b/go.sum @@ -11,8 +11,6 @@ github.com/Microsoft/hcsshim v0.9.4 h1:mnUj0ivWy6UzbB1uLFqKR6F+ZyiDc7j4iGgHTpO+5 github.com/Microsoft/hcsshim v0.9.4/go.mod h1:7pLA8lDk46WKDWlVsENo92gC0XFa8rbKfyFRBqxEbCc= github.com/aead/cmac v0.0.0-20160719120800-7af84192f0b1 h1:+JkXLHME8vLJafGhOH4aoV2Iu8bR55nU6iKMVfYVLjY= github.com/aead/cmac v0.0.0-20160719120800-7af84192f0b1/go.mod h1:nuudZmJhzWtx2212z+pkuy7B6nkBqa+xwNXZHL1j8cg= -github.com/antonfisher/nested-logrus-formatter v1.3.1 h1:NFJIr+pzwv5QLHTPyKz9UMEoHck02Q9L0FP13b/xSbQ= -github.com/antonfisher/nested-logrus-formatter v1.3.1/go.mod h1:6WTfyWFkBc9+zyBaKIqRrg/KwMqBbodBjgbHjDz7zjA= github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ= github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/avast/retry-go/v4 v4.1.0 h1:CwudD9anYv6JMVnDuTRlK6kLo4dBamiL+F3U8YDiyfg= @@ -112,7 +110,6 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -120,7 +117,6 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= @@ -140,7 +136,6 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7 github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= @@ -148,11 +143,8 @@ github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa02 github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= @@ -184,9 +176,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= -github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= -github.com/montanaflynn/stats v0.6.6 h1:Duep6KMIDpY4Yo11iFsvyqJDyfzLF9+sndUKT+v64GQ= -github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= +github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE= +github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= @@ -195,20 +186,18 @@ github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= -github.com/omec-project/amf v1.4.5 h1:RqdHtE3VgtoGERsuShlh+RiAy975GQxb0vjunSK1xQI= -github.com/omec-project/amf v1.4.5/go.mod h1:fDstgrCWxMnjbn7sLYThMlxyOg6ossKdTp0exxO/Y9E= +github.com/omec-project/amf v1.5.0 h1:6C9KyHPYlx1F2CX2pJieZPH44zBJPWyN5LlcPICQ7ds= +github.com/omec-project/amf v1.5.0/go.mod h1:UDIgvJp1I4vrXapq/DEmh8fIfVbu0fgH425bwsiNgZU= github.com/omec-project/aper v1.2.1 h1:A4KhlTMta5mUA1DX2njOjOn0SuFi5WoWnSqdbRnl9Q8= github.com/omec-project/aper v1.2.1/go.mod h1:CbCZ0uNmcD3XA4YM6wBwpqP1PYtGAaC3RqLL4B5gG2U= -github.com/omec-project/metricfunc v1.4.1 h1:n1EajFuGaHs9wouLL2GOBEt1oWj074dXei/NWLGNDaw= -github.com/omec-project/metricfunc v1.4.1/go.mod h1:biEfEyPV0KdhwYMQEcDFwuju7vQfx7fAvgDdc8MvF84= -github.com/omec-project/nas v1.3.0 h1:zNqEQSNTsupT3qP6keSuOusOHKrqEYoC5ghKR8TpKEQ= -github.com/omec-project/nas v1.3.0/go.mod h1:So4hpY95XZTpX0Joco/axIH4MlO0o13UT1rWQWZEuLQ= +github.com/omec-project/nas v1.4.1 h1:Ui3k5TnOQ8IGt09qUboaZ05IuMuVSbjZ54Y7iy85iVs= +github.com/omec-project/nas v1.4.1/go.mod h1:R0x9ehAHi/CUdsMWP+XmefjloEGwobkqz1/c8308yBo= github.com/omec-project/ngap v1.3.0 h1:NuAc6GZRup6E3jg+fGTy8aR4VkOlB1mnkaaYr6OGmMc= github.com/omec-project/ngap v1.3.0/go.mod h1:XBHem/s2xtRNCLPgH7Ubs7i72BTAvK1EILTWf7iQ0ao= github.com/omec-project/openapi v1.3.1 h1:NCteMRdMtWnMhf1CXYduuLgeu8fEhc/7XO1CiE7fN3Y= github.com/omec-project/openapi v1.3.1/go.mod h1:cR6Iharp2TLOzEmskQ/EdCVFZnpKh0zTvUSSuyXAYLE= -github.com/omec-project/util v1.1.0 h1:TUuLmzqTLChIEXQlK9g5Ihgmw4FUm/UJnjfu0wT8Gz0= -github.com/omec-project/util v1.1.0/go.mod h1:BEv8nCokB4j0fgAQ6VVkKuQ2PSP3DJMEmz25pFMw5X8= +github.com/omec-project/util v1.2.1 h1:+o5kbnZzKBmbqT4oprVGPgL0jH5b8BvRMfLye5srGQ4= +github.com/omec-project/util v1.2.1/go.mod h1:kUF2LXhmtw+m7Bk5IGOMFLj7CA8VKtilLI/9QBJcfxE= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= @@ -229,8 +218,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.20.3 h1:oPksm4K8B+Vt35tUhw6GbSNSgVlVSBH0qELP/7u83l4= -github.com/prometheus/client_golang v1.20.3/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= +github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI= +github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= @@ -256,7 +245,6 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= @@ -268,8 +256,6 @@ github.com/testcontainers/testcontainers-go v0.13.0 h1:OUujSlEGsXVo/ykPVZk3KanBN github.com/testcontainers/testcontainers-go v0.13.0/go.mod h1:z1abufU633Eb/FmSBTzV6ntZAC1eZBYPtaFsn4nPuDk= github.com/thakurajayL/go-ipam v0.0.5-dev h1:EgOkLUKjGqVLjQ5RKK14x2W/EUhSm8bPjiAC0g1tyPw= github.com/thakurajayL/go-ipam v0.0.5-dev/go.mod h1:kriWKdZOK9c1i9XAEjx+FfEAjzV/mx2YL3Jl4dhJ3IY= -github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= -github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= @@ -278,17 +264,14 @@ github.com/urfave/cli v1.22.15 h1:nuqt+pdC/KqswQKhETJjo7pvn/k4xMUxgW6liI7XpnM= github.com/urfave/cli v1.22.15/go.mod h1:wSan1hmo5zeyLGBjRJbzRTNk8gwoYa2B9n4q9dmRIc0= github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= -github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY= github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4= -github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8= github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8= github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= github.com/yerden/go-util v1.1.4 h1:jd8JyjLHzpEs1ZZQzDkfRgosDtXp/BtIAV1kpNjVTtw= github.com/yerden/go-util v1.1.4/go.mod h1:3HeLrvtkEeAv67ARostM9Yn0DcAVqgJ3uAiCuywEEXk= -github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= -github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a h1:fZHgsYlfvtyqToslyjUt3VOPF4J7aK/3MPcK7xp3PDk= -github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a/go.mod h1:ul22v+Nro/R083muKhosV54bj5niojjWZvU8xrevuH4= +github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM= +github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= @@ -299,8 +282,8 @@ go.etcd.io/etcd/client/pkg/v3 v3.5.12 h1:EYDL6pWwyOsylrQyLp2w+HkQ46ATiOvoEdMarin go.etcd.io/etcd/client/pkg/v3 v3.5.12/go.mod h1:seTzl2d9APP8R5Y2hFL3NVlD6qC/dOT+3kvrqPyTas4= go.etcd.io/etcd/client/v3 v3.5.12 h1:v5lCPXn1pf1Uu3M4laUE2hp/geOTc5uPcYYsNe1lDxg= go.etcd.io/etcd/client/v3 v3.5.12/go.mod h1:tSbBCakoWmmddL+BKVAJHa9km+O/E+bumDe9mSbPiqw= -go.mongodb.org/mongo-driver v1.11.7 h1:LIwYxASDLGUg/8wOhgOOZhX8tQa/9tgZPgzZoVqJvcs= -go.mongodb.org/mongo-driver v1.11.7/go.mod h1:G9TgswdsWjX4tmDA5zfs2+6AEPpYJwqblyjsfuh8oXY= +go.mongodb.org/mongo-driver v1.17.0 h1:Hp4q2MCjvY19ViwimTs00wHi7G4yzxh4/2+nTx8r40k= +go.mongodb.org/mongo-driver v1.17.0/go.mod h1:wwWm/+BuOddhcq3n68LKRmgk2wXzmF6s0SFOa0GINL4= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= @@ -321,10 +304,8 @@ golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc= golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= @@ -348,7 +329,6 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= @@ -380,7 +360,6 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211107104306-e0b2ad06fe42/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -424,17 +403,17 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117 h1:+rdxYoE3E5htTEWIe15GlN6IfvbURM//Jt0mmkmm6ZU= -google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117/go.mod h1:OimBR/bc1wPO9iV4NC2bpyjy3VnAwZh5EBPQdtaE5oo= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 h1:1GBuWVLM/KMVUv1t1En5Gs+gFZCNd360GGb4sSxtrhU= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= +google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8= +google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.66.2 h1:3QdXkuq3Bkh7w+ywLdLvM56cmGvQHUMZpiCzt6Rqaoo= -google.golang.org/grpc v1.66.2/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= +google.golang.org/grpc v1.67.0 h1:IdH9y6PF5MPSdAntIcpjQ+tXO41pcQsfZV2RxtQgVcw= +google.golang.org/grpc v1.67.0/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -447,7 +426,6 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/h2non/gock.v1 v1.1.2 h1:jBbHXgGBK/AoPVfJh5x4r/WxIrElvbLel8TCZkkZJoY= diff --git a/httpserver/server.go b/httpserver/server.go index e6b09525..f4db96bb 100644 --- a/httpserver/server.go +++ b/httpserver/server.go @@ -7,7 +7,6 @@ package httpserver import ( "fmt" - "log" "net/http" "time" @@ -16,7 +15,7 @@ import ( "github.com/omec-project/gnbsim/logger" profilerouter "github.com/omec-project/gnbsim/profile/httprouter" "github.com/omec-project/util/http2_util" - logger_util "github.com/omec-project/util/logger" + utilLogger "github.com/omec-project/util/logger" "golang.org/x/net/context" ) @@ -28,7 +27,7 @@ const ( ) func StartHttpServer() (err error) { - router := logger_util.NewGinWithLogrus(logger.GinLog) + router := utilLogger.NewGinWithZap(logger.GinLog) router.Use(cors.New(cors.Config{ AllowMethods: []string{"GET", "POST", "OPTIONS", "PUT", "PATCH", "DELETE"}, AllowHeaders: []string{ @@ -49,12 +48,12 @@ func StartHttpServer() (err error) { server, err = http2_util.NewServer(serverAddr, logFile, router) if server == nil { - logger.AppLog.Errorf("Initialize HTTP server failed: %+v", err) + logger.AppLog.Errorf("initialize HTTP server failed: %+v", err) return fmt.Errorf("failed to initialize http server, err: %v", err) } if err != nil { - logger.AppLog.Warnf("Initialize HTTP server: %+v", err) + logger.AppLog.Warnf("initialize HTTP server: %+v", err) return fmt.Errorf("failed to initialize http server, err: %v", err) } @@ -79,6 +78,6 @@ func StopHttpServer() { }() if err := server.Shutdown(ctx); err != nil { - log.Fatalf("Server shutdown Failed:%+v", err) + logger.HttpLog.Fatalf("server shutdown failed:%+v", err) } } diff --git a/logger/logger.go b/logger/logger.go index 52ce153e..0da09b3a 100644 --- a/logger/logger.go +++ b/logger/logger.go @@ -1,3 +1,4 @@ +// SPDX-FileCopyrightText: 2024 Intel Corporation // SPDX-FileCopyrightText: 2022 Great Software Laboratory Pvt. Ltd // SPDX-FileCopyrightText: 2021 Open Networking Foundation // Copyright 2019 free5GC.org @@ -7,32 +8,29 @@ package logger import ( - "os" - "time" - - formatter "github.com/antonfisher/nested-logrus-formatter" - logger_util "github.com/omec-project/util/logger" - "github.com/sirupsen/logrus" + "go.uber.org/zap" + "go.uber.org/zap/zapcore" ) var ( - log *logrus.Logger - summaryLog *logrus.Logger - AppLog *logrus.Entry - AppSummaryLog *logrus.Entry - RealUeLog *logrus.Entry - SimUeLog *logrus.Entry - ProfileLog *logrus.Entry - GNodeBLog *logrus.Entry - CfgLog *logrus.Entry - UtilLog *logrus.Entry - GtpLog *logrus.Entry - NgapLog *logrus.Entry - PsuppLog *logrus.Entry - GinLog *logrus.Entry - HttpLog *logrus.Entry - ProfUeCtxLog *logrus.Entry - StatsLog *logrus.Entry + log *zap.Logger + summaryLog *zap.Logger + AppLog *zap.SugaredLogger + AppSummaryLog *zap.SugaredLogger + RealUeLog *zap.SugaredLogger + SimUeLog *zap.SugaredLogger + ProfileLog *zap.SugaredLogger + GNodeBLog *zap.SugaredLogger + CfgLog *zap.SugaredLogger + UtilLog *zap.SugaredLogger + GtpLog *zap.SugaredLogger + NgapLog *zap.SugaredLogger + PsuppLog *zap.SugaredLogger + GinLog *zap.SugaredLogger + HttpLog *zap.SugaredLogger + ProfUeCtxLog *zap.SugaredLogger + StatsLog *zap.SugaredLogger + atomicLevel zap.AtomicLevel ) const ( @@ -46,67 +44,77 @@ const ( ) func init() { - log = logrus.New() - summaryLog = logrus.New() - log.SetReportCaller(false) - summaryLog.SetReportCaller(false) - - log.Formatter = &formatter.Formatter{ - TimestampFormat: time.RFC3339, - TrimMessages: true, - NoFieldsSpace: true, - HideKeys: true, - FieldsOrder: []string{ - "component", "category", "subcategory", - FieldProfile, FieldSupi, FieldGnb, FieldGnbUeNgapId, - }, + atomicLevel = zap.NewAtomicLevelAt(zap.InfoLevel) + config := zap.Config{ + Level: atomicLevel, + Development: false, + Encoding: "console", + EncoderConfig: zap.NewProductionEncoderConfig(), + OutputPaths: []string{"stdout", "gnbsim.log"}, + ErrorOutputPaths: []string{"stderr"}, } - summaryLog.Formatter = &formatter.Formatter{ - TimestampFormat: time.RFC3339, - TrimMessages: true, - NoFieldsSpace: true, - HideKeys: true, - FieldsOrder: []string{"component", "category"}, - } + config.EncoderConfig.TimeKey = "timestamp" + config.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder + config.EncoderConfig.LevelKey = "level" + config.EncoderConfig.EncodeLevel = zapcore.CapitalLevelEncoder + config.EncoderConfig.CallerKey = "caller" + config.EncoderConfig.EncodeCaller = zapcore.ShortCallerEncoder + config.EncoderConfig.MessageKey = "message" + config.EncoderConfig.StacktraceKey = "" - selfLogHook, err := logger_util.NewFileHook("gnbsim.log", - os.O_CREATE|os.O_APPEND|os.O_RDWR, 0o666) - if err == nil { - log.Hooks.Add(selfLogHook) + var err error + log, err = config.Build() + if err != nil { + panic(err) } - summaryLogHook, err := logger_util.NewFileHook("summary.log", - os.O_CREATE|os.O_APPEND|os.O_RDWR, 0o666) - if err == nil { - summaryLog.Hooks.Add(summaryLogHook) + configSummary := zap.Config{ + Level: atomicLevel, + Development: false, + Encoding: "console", + EncoderConfig: zap.NewProductionEncoderConfig(), + OutputPaths: []string{"stdout", "summary.log"}, + ErrorOutputPaths: []string{"stderr"}, } - AppLog = log.WithFields(logrus.Fields{"component": "GNBSIM", "category": "App"}) - AppSummaryLog = summaryLog.WithFields(logrus.Fields{"component": "GNBSIM", "category": "Summary"}) - RealUeLog = log.WithFields(logrus.Fields{"component": "GNBSIM", "category": "RealUe"}) - SimUeLog = log.WithFields(logrus.Fields{"component": "GNBSIM", "category": "SimUe"}) - ProfUeCtxLog = log.WithFields(logrus.Fields{"component": "GNBSIM", "category": "ProfUeCtx"}) - ProfileLog = log.WithFields(logrus.Fields{"component": "GNBSIM", "category": "Profile"}) - GNodeBLog = log.WithFields(logrus.Fields{"component": "GNBSIM", "category": "GNodeB"}) - GinLog = log.WithFields(logrus.Fields{"component": "GNBSIM", "category": "Gin"}) - HttpLog = log.WithFields(logrus.Fields{"component": "GNBSIM", "category": "HTTP"}) - CfgLog = log.WithFields(logrus.Fields{"component": "GNBSIM", "category": "CFG"}) - StatsLog = log.WithFields(logrus.Fields{"component": "GNBSIM", "category": "Stats"}) - UtilLog = log.WithFields(logrus.Fields{"component": "GNBSIM", "category": "Util"}) - GtpLog = UtilLog.WithField("subcategory", "GTP") - NgapLog = UtilLog.WithField("subcategory", "NGAP") - PsuppLog = UtilLog.WithField("subcategory", "PSUPP") -} + configSummary.EncoderConfig.TimeKey = "timestamp" + configSummary.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder + configSummary.EncoderConfig.LevelKey = "level" + configSummary.EncoderConfig.EncodeLevel = zapcore.CapitalLevelEncoder + configSummary.EncoderConfig.CallerKey = "caller" + configSummary.EncoderConfig.EncodeCaller = zapcore.ShortCallerEncoder + configSummary.EncoderConfig.MessageKey = "message" + configSummary.EncoderConfig.StacktraceKey = "" -func SetLogLevel(level string) { - lvl, err := logrus.ParseLevel(level) + summaryLog, err = configSummary.Build() if err != nil { - AppLog.Fatalln("Failed to parse log level:", err) + panic(err) } - log.SetLevel(lvl) + + AppLog = log.Sugar().With("component", "GNBSIM", "category", "App") + AppSummaryLog = summaryLog.Sugar().With("component", "GNBSIM", "category", "Summary") + RealUeLog = log.Sugar().With("component", "GNBSIM", "category", "RealUe") + SimUeLog = log.Sugar().With("component", "GNBSIM", "category", "SimUe") + ProfUeCtxLog = log.Sugar().With("component", "GNBSIM", "category", "ProfUeCtx") + ProfileLog = log.Sugar().With("component", "GNBSIM", "category", "Profile") + GNodeBLog = log.Sugar().With("component", "GNBSIM", "category", "GNodeB") + GinLog = log.Sugar().With("component", "GNBSIM", "category", "Gin") + HttpLog = log.Sugar().With("component", "GNBSIM", "category", "HTTP") + CfgLog = log.Sugar().With("component", "GNBSIM", "category", "CFG") + StatsLog = log.Sugar().With("component", "GNBSIM", "category", "Stats") + UtilLog = log.Sugar().With("component", "GNBSIM", "category", "Util") + GtpLog = UtilLog.With("subcategory", "GTP") + NgapLog = UtilLog.With("subcategory", "NGAP") + PsuppLog = UtilLog.With("subcategory", "PSUPP") +} + +func GetLogger() *zap.Logger { + return log } -func SetReportCaller(set bool) { - log.SetReportCaller(set) +// SetLogLevel: set the log level (panic|fatal|error|warn|info|debug) +func SetLogLevel(level zapcore.Level) { + AppLog.Infoln("set log level:", level) + atomicLevel.SetLevel(level) } diff --git a/profile/context/profile.go b/profile/context/profile.go index 7c3e2772..4cca92f5 100644 --- a/profile/context/profile.go +++ b/profile/context/profile.go @@ -12,7 +12,7 @@ import ( "github.com/omec-project/gnbsim/common" "github.com/omec-project/gnbsim/logger" "github.com/omec-project/openapi/models" - "github.com/sirupsen/logrus" + "go.uber.org/zap" ) // profile names @@ -66,7 +66,7 @@ type ProfileUeContext struct { WriteSimChan chan common.InterfaceMessage // Sending events to SIMUE - start proc and proc parameters ReadChan chan *common.ProfileMessage // Sending events to profile - Log *logrus.Entry + Log *zap.SugaredLogger CurrentItr string // used only if UE is part of custom profile Repeat int // used only if UE is part of custom profile @@ -87,7 +87,7 @@ type Profile struct { StartIteration string `yaml:"startiteration" json:"startiteration"` Plmn *models.PlmnId `yaml:"plmnId" json:"plmnId"` SNssai *models.Snssai `yaml:"sNssai" json:"sNssai"` - Log *logrus.Entry + Log *zap.SugaredLogger // Profile routine reads messages from other entities on this channel // Entities can be SimUe, Main routine. @@ -198,7 +198,7 @@ func initProcedureEventMap() { func (profile *Profile) Init() error { profile.ReadChan = make(chan *common.ProfileMessage) profile.PSimUe = make(map[string]*ProfileUeContext) - profile.Log = logger.ProfileLog.WithField(logger.FieldProfile, profile.Name) + profile.Log = logger.ProfileLog.With(logger.FieldProfile, profile.Name) if profile.DataPktCount == 0 { profile.DataPktCount = 5 // default } @@ -216,7 +216,7 @@ func (profile *Profile) Init() error { } ProfileMap[profile.Name] = profile - profile.Log.Traceln("profile initialized ", profile.Name, ", Enable ", profile.Enable) + profile.Log.Debugln("profile initialized", profile.Name, ", Enable", profile.Enable) return nil } @@ -332,7 +332,7 @@ func (p *Profile) GetNextProcedure(pCtx *ProfileUeContext, currentProcedure comm nextProcedure = p.Procedures[i+1] break } - p.Log.Infoln("No more procedures left") + p.Log.Infoln("no more procedures left") } } return nextProcedure @@ -340,8 +340,8 @@ func (p *Profile) GetNextProcedure(pCtx *ProfileUeContext, currentProcedure comm // check if custom Profile if len(p.Iterations) > 0 { - pCtx.Log.Infoln("Current UE iteration ", pCtx.CurrentItr) - pCtx.Log.Infoln("Current UE procedure index ", pCtx.CurrentProcIndex) + pCtx.Log.Infoln("Current UE iteration", pCtx.CurrentItr) + pCtx.Log.Infoln("Current UE procedure index", pCtx.CurrentProcIndex) itp := p.PIterations[pCtx.CurrentItr] pCtx.Log.Infoln("Current Iteration map - ", itp) if itp.WaitMap[pCtx.CurrentProcIndex] != 0 { @@ -359,17 +359,17 @@ func (p *Profile) GetNextProcedure(pCtx *ProfileUeContext, currentProcedure comm } if pCtx.Repeat > 0 { pCtx.Repeat = pCtx.Repeat - 1 - pCtx.Log.Infoln("Repeat current iteration : ", itp.Name, ", Repeat Count ", pCtx.Repeat) + pCtx.Log.Infoln("Repeat current iteration:", itp.Name, ", Repeat Count", pCtx.Repeat) pCtx.CurrentProcIndex = 1 nextProcedure = itp.ProcMap[1] pCtx.Procedure = nextProcedure return nextProcedure } - pCtx.Log.Infoln("Iteration Complete ", pCtx.CurrentItr) + pCtx.Log.Infoln("Iteration Complete", pCtx.CurrentItr) nextItr := itp.NextItr if nextItr != "quit" { nItr := p.PIterations[nextItr] - pCtx.Log.Infoln("Going to next iteration ", nItr.Name) + pCtx.Log.Infoln("Going to next iteration", nItr.Name) pCtx.CurrentItr = nItr.Name pCtx.CurrentProcIndex = 1 pCtx.Repeat = nItr.Repeat @@ -378,6 +378,6 @@ func (p *Profile) GetNextProcedure(pCtx *ProfileUeContext, currentProcedure comm return nextProcedure } } - pCtx.Log.Infoln("Nothing more to execute for UE") + pCtx.Log.Infoln("nothing more to execute for UE") return nextProcedure } diff --git a/profile/httprouter/handler.go b/profile/httprouter/handler.go index e624f53c..dea108c4 100644 --- a/profile/httprouter/handler.go +++ b/profile/httprouter/handler.go @@ -22,10 +22,10 @@ import ( ) func HTTPStepProfile(c *gin.Context) { - logger.HttpLog.Infoln("HTTPStepProfile!") + logger.HttpLog.Infoln("HTTPStepProfile") profName, exists := c.Params.Get("profile-name") if !exists { - logger.HttpLog.Printf("Received HTTPStepProfile, but profile-name not found ") + logger.HttpLog.Warnln("received HTTPStepProfile but profile-name not found") c.JSON(http.StatusBadRequest, gin.H{}) return } @@ -42,7 +42,7 @@ func HTTPAddNewCallsProfile(c *gin.Context) { logger.HttpLog.Infoln("HTTPAddNewCallsProfile!") profName, exists := c.Params.Get("profile-name") if !exists { - logger.HttpLog.Printf("Received HTTPAddNewCallsProfile, but profile-name not found ") + logger.HttpLog.Warnln("received HTTPAddNewCallsProfile, but profile-name not found") c.JSON(http.StatusBadRequest, gin.H{}) return } @@ -101,12 +101,12 @@ func HTTPExecuteConfigProfile(c *gin.Context) { } func HTTPExecuteProfile(c *gin.Context) { - logger.HttpLog.Infoln("EcecuteProfile API called") + logger.HttpLog.Infoln("ExecuteProfile API called") var prof profCtx.Profile requestBody, err := c.GetRawData() if err != nil { - logger.HttpLog.Errorf("Get Request Body error: %+v", err) + logger.HttpLog.Errorf("get Request Body error: %+v", err) problemDetail := models.ProblemDetails{ Title: "System failure", Status: http.StatusInternalServerError, diff --git a/profile/httprouter/router.go b/profile/httprouter/router.go index 1672a0c3..c4057d59 100644 --- a/profile/httprouter/router.go +++ b/profile/httprouter/router.go @@ -10,7 +10,7 @@ import ( "github.com/gin-gonic/gin" "github.com/omec-project/gnbsim/logger" - logger_util "github.com/omec-project/util/logger" + utilLogger "github.com/omec-project/util/logger" ) // Route is the information for every URI. @@ -30,7 +30,7 @@ type Routes []Route // NewRouter returns a new router. func NewRouter() *gin.Engine { - router := logger_util.NewGinWithLogrus(logger.GinLog) + router := utilLogger.NewGinWithZap(logger.GinLog) AddService(router) return router } diff --git a/profile/ngsetup/ngsetup.go b/profile/ngsetup/ngsetup.go index 6000267a..0eb737da 100644 --- a/profile/ngsetup/ngsetup.go +++ b/profile/ngsetup/ngsetup.go @@ -5,7 +5,6 @@ package ngsetup import ( - "fmt" "net" "github.com/omec-project/gnbsim/factory" @@ -24,7 +23,7 @@ func NgSetup_test(profile *profctx.Profile) { addrs, err := net.LookupHost("amf") if err != nil { - fmt.Println("Failed to resolve amf") + profile.Log.Errorln("failed to resolve amf") return } diff --git a/profile/profile.go b/profile/profile.go index 05ca3681..0c2397a1 100644 --- a/profile/profile.go +++ b/profile/profile.go @@ -82,7 +82,7 @@ func initImsi(profile *profctx.Profile, gnb *gnbctx.GNodeB, imsiStr string) { p.ReadChan = readChan trigChan := make(chan *common.ProfileMessage) p.TrigEventsChan = trigChan - p.Log = logger.ProfUeCtxLog.WithField(logger.FieldSupi, imsiStr) + p.Log = logger.ProfUeCtxLog.With(logger.FieldSupi, imsiStr) profile.PSimUe[imsiStr] = &p } @@ -116,7 +116,7 @@ func ExecuteProfile(profile *profctx.Profile, summaryChan chan common.InterfaceM go func() { var plock sync.Mutex for msg := range profile.ReadChan { - profile.Log.Infoln("Received trigger for profile ", msg) + profile.Log.Infoln("received trigger for profile", msg) // works only if profile is still running. // Typically if execInParallel set true in profile gnb, err := factory.AppConfig.Configuration.GetGNodeB(profile.GnbName) @@ -133,7 +133,7 @@ func ExecuteProfile(profile *profctx.Profile, summaryChan chan common.InterfaceM imsiStr := makeImsiStr(profile, imsi) initImsi(profile, gnb, imsiStr) pCtx := profile.PSimUe[imsiStr] - profile.Log.Infoln("pCtx ", pCtx) + profile.Log.Infoln("pCtx", pCtx) wg.Add(1) go func(pCtx *profctx.ProfileUeContext) { defer wg.Done() @@ -202,9 +202,9 @@ func SendStepEventProfile(name string) error { // msg.ProcedureType = msg.Event = common.PROFILE_STEP_EVENT for _, ctx := range profile.PSimUe { - profile.Log.Traceln("profile ", profile, ", writing on trig channel - start") + profile.Log.Debugln("profile", profile, ", writing on trig channel - start") ctx.TrigEventsChan <- msg - profile.Log.Traceln("profile ", profile, ", writing on trig channel - end") + profile.Log.Debugln("profile", profile, ", writing on trig channel - end") } return nil } @@ -219,9 +219,9 @@ func SendAddNewCallsEventProfile(name string, number int32) error { msg.Event = common.PROFILE_ADDCALLS_EVENT var i int32 for i = 0; i < number; i++ { - profile.Log.Traceln("profile ", profile, ", writing on trig channel - start") + profile.Log.Debugln("profile", profile, ", writing on trig channel - start") profile.ReadChan <- msg - profile.Log.Traceln("profile ", profile, ", writing on trig channel - end") + profile.Log.Debugln("profile", profile, ", writing on trig channel - end") } return nil } diff --git a/realue/context/pdusession.go b/realue/context/pdusession.go index cabfd071..405c3d03 100644 --- a/realue/context/pdusession.go +++ b/realue/context/pdusession.go @@ -10,7 +10,7 @@ import ( "github.com/omec-project/gnbsim/common" "github.com/omec-project/gnbsim/logger" "github.com/omec-project/openapi/models" - "github.com/sirupsen/logrus" + "go.uber.org/zap" ) /* PduSession represents a PDU Session in Real UE. It listens for DL user data @@ -30,7 +30,7 @@ type PduSession struct { // commands from RealUE control plane are read on this channel ReadCmdChan chan common.InterfaceMessage - Log *logrus.Entry + Log *zap.SugaredLogger /* Number of UL data packets to be transmitted as requested by Sim UE*/ Snssai models.Snssai @@ -56,11 +56,8 @@ func NewPduSession(realUe *RealUe, pduSessId int64) *PduSession { pduSess.PduSessId = pduSessId pduSess.ReadDlChan = make(chan common.InterfaceMessage, 10) pduSess.ReadCmdChan = make(chan common.InterfaceMessage, 10) - pduSess.Log = realUe.Log.WithFields(logrus.Fields{ - "subcategory": "PduSession", - logger.FieldPduSessId: pduSessId, - }) - pduSess.Log.Traceln("Pdu Session Created") + pduSess.Log = realUe.Log.With("subcategory", "PduSession", logger.FieldPduSessId, pduSessId) + pduSess.Log.Debugln("pdu session created") return &pduSess } diff --git a/realue/context/realue.go b/realue/context/realue.go index f94b96cf..82a3b395 100644 --- a/realue/context/realue.go +++ b/realue/context/realue.go @@ -19,7 +19,7 @@ import ( "github.com/omec-project/openapi/models" "github.com/omec-project/util/milenage" "github.com/omec-project/util/ueauth" - "github.com/sirupsen/logrus" + "go.uber.org/zap" ) // RealUe represents a Real UE @@ -33,7 +33,7 @@ type RealUe struct { SNssai *models.Snssai AuthenticationSubs *models.AuthenticationSubscription Plmn *models.PlmnId - Log *logrus.Entry + Log *zap.SugaredLogger // RealUe writes messages to SimUE on this channel WriteSimUeChan chan common.InterfaceMessage @@ -71,9 +71,9 @@ func NewRealUe(supi string, cipheringAlg, integrityAlg uint8, ue.WriteSimUeChan = simuechan ue.PduSessions = make(map[int64]*PduSession) ue.ReadChan = make(chan common.InterfaceMessage, 5) - ue.Log = logger.RealUeLog.WithField(logger.FieldSupi, supi) + ue.Log = logger.RealUeLog.With(logger.FieldSupi, supi) - ue.Log.Traceln("Created new context") + ue.Log.Debugln("created new context") return &ue } @@ -183,7 +183,7 @@ func (ue *RealUe) DeriveRESstarAndSetKey( ue.DerivateAlgKey() kdfVal_for_resStar, err := ueauth.GetKDFValue(key, FC, P0, ueauth.KDFLen(P0), P1, ueauth.KDFLen(P1), P2, ueauth.KDFLen(P2)) if err != nil { - ue.Log.Fatalf("Error getting KDF value: %+v", err) + ue.Log.Fatalf("error getting KDF value: %+v", err) } return kdfVal_for_resStar[len(kdfVal_for_resStar)/2:] } @@ -198,12 +198,12 @@ func (ue *RealUe) DerivateKamf(key []byte, snName string, SQN, AK []byte) { P1 := SQNxorAK Kausf, err := ueauth.GetKDFValue(key, FC, P0, ueauth.KDFLen(P0), P1, ueauth.KDFLen(P1)) if err != nil { - ue.Log.Fatalf("Error getting KDF value: %+v", err) + ue.Log.Fatalf("error getting KDF value: %+v", err) } P0 = []byte(snName) Kseaf, err := ueauth.GetKDFValue(Kausf, ueauth.FC_FOR_KSEAF_DERIVATION, P0, ueauth.KDFLen(P0)) if err != nil { - ue.Log.Fatalf("Error getting KDF value: %+v", err) + ue.Log.Fatalf("error getting KDF value: %+v", err) } supiRegexp, err := regexp.Compile("(?:imsi|supi)-([0-9]{5,15})") @@ -219,7 +219,7 @@ func (ue *RealUe) DerivateKamf(key []byte, snName string, SQN, AK []byte) { ue.Kamf, err = ueauth.GetKDFValue(Kseaf, ueauth.FC_FOR_KAMF_DERIVATION, P0, L0, P1, L1) if err != nil { - ue.Log.Fatalf("Error getting KDF value: %+v", err) + ue.Log.Fatalf("error getting KDF value: %+v", err) } } @@ -233,7 +233,7 @@ func (ue *RealUe) DerivateAlgKey() { kenc, err := ueauth.GetKDFValue(ue.Kamf, ueauth.FC_FOR_ALGORITHM_KEY_DERIVATION, P0, L0, P1, L1) if err != nil { - ue.Log.Fatalf("Error getting KDF value: %+v", err) + ue.Log.Fatalf("error getting KDF value: %+v", err) } copy(ue.KnasEnc[:], kenc[16:32]) @@ -245,7 +245,7 @@ func (ue *RealUe) DerivateAlgKey() { kint, err := ueauth.GetKDFValue(ue.Kamf, ueauth.FC_FOR_ALGORITHM_KEY_DERIVATION, P0, L0, P1, L1) if err != nil { - ue.Log.Fatalf("Error getting KDF value: %+v", err) + ue.Log.Fatalf("error getting KDF value: %+v", err) } copy(ue.KnasInt[:], kint[16:32]) } @@ -260,7 +260,7 @@ func (ue *RealUe) Get5GMMCapability() (capability5GMM *nasType.Capability5GMM) { // GetPduSession returns the PduSession instance corresponding to provided PDU Sess ID func (ctx *RealUe) GetPduSession(pduSessId int64) (*PduSession, error) { - ctx.Log.Infoln("Fetching PDU Session for pduSessId:", pduSessId) + ctx.Log.Infoln("fetching PDU Session for pduSessId:", pduSessId) val, ok := ctx.PduSessions[pduSessId] if ok { return val, nil @@ -271,6 +271,6 @@ func (ctx *RealUe) GetPduSession(pduSessId int64) (*PduSession, error) { // AddPduSession adds the PduSession instance corresponding to provided PDU Sess ID func (ctx *RealUe) AddPduSession(pduSessId int64, pduSess *PduSession) { - ctx.Log.Infoln("Adding new PDU Session for PDU Sess ID:", pduSessId) + ctx.Log.Infoln("adding new PDU Session for PDU Sess ID:", pduSessId) ctx.PduSessions[pduSessId] = pduSess } diff --git a/realue/handler.go b/realue/handler.go index 46a324d8..2c0c08ad 100644 --- a/realue/handler.go +++ b/realue/handler.go @@ -47,13 +47,13 @@ func HandleRegRequestEvent(ue *realuectx.RealUe, Len: uint16(len(ue.Suci)), // suci Buffer: ue.Suci, } - ue.Log.Traceln("Generating SUPI Registration Request Message") + ue.Log.Debugln("generating SUPI Registration Request Message") nasPdu := nasTestpacket.GetRegistrationRequest(nasMessage.RegistrationType5GSInitialRegistration, mobileId5GS, nil, ueSecurityCapability, nil, nil, nil) m := formUuMessage(common.REG_REQUEST_EVENT, nasPdu, id) SendToSimUe(ue, m) - ue.Log.Traceln("Sent Registration Request Message to SimUe") + ue.Log.Debugln("sent Registration Request Message to SimUe") return nil } @@ -68,7 +68,7 @@ func HandleAuthResponseEvent(ue *realuectx.RealUe, msg.Id = id // First process the corresponding Auth Request - ue.Log.Traceln("Processing corresponding Authentication Request Message") + ue.Log.Debugln("processing corresponding Authentication Request Message") authReq := msg.NasMsg.AuthenticationRequest ue.NgKsi = nasConvert.SpareHalfOctetAndNgksiToModels(authReq.SpareHalfOctetAndNgksi) @@ -90,12 +90,12 @@ func HandleAuthResponseEvent(ue *realuectx.RealUe, // TODO: Parse Auth Request IEs and update the RealUE Context // Now generate NAS Authentication Response - ue.Log.Traceln("Generating Authentication Response Message") + ue.Log.Debugln("generating Authentication Response Message") nasPdu := nasTestpacket.GetAuthenticationResponse(resStat, "") m := formUuMessage(common.AUTH_RESPONSE_EVENT, nasPdu, id) SendToSimUe(ue, m) - ue.Log.Traceln("Sent Authentication Response Message to SimUe") + ue.Log.Debugln("sent Authentication Response Message to SimUe") return nil } @@ -112,7 +112,7 @@ func HandleSecModCompleteEvent(ue *realuectx.RealUe, nasMessage.RegistrationType5GSInitialRegistration, mobileId5GS, nil, ue.GetUESecurityCapability(), ue.Get5GMMCapability(), nil, nil) - ue.Log.Traceln("Generating Security Mode Complete Message") + ue.Log.Debugln("generating Security Mode Complete Message") nasPdu := nasTestpacket.GetSecurityModeComplete(registrationRequestWith5GMM) nasPdu, err = realue_nas.EncodeNasPduWithSecurity(ue, nasPdu, @@ -129,7 +129,7 @@ func HandleSecModCompleteEvent(ue *realuectx.RealUe, m := formUuMessage(common.SEC_MOD_COMPLETE_EVENT, nasPdu, id) SendToSimUe(ue, m) - ue.Log.Traceln("Sent Security Mode Complete Message to SimUe") + ue.Log.Debugln("sent Security Mode Complete Message to SimUe") return nil } @@ -146,7 +146,7 @@ func HandleRegCompleteEvent(ue *realuectx.RealUe, _, ue.Guti = nasConvert.GutiToString(guti) - ue.Log.Traceln("Generating Registration Complete Message") + ue.Log.Debugln("generating Registration Complete Message") nasPdu := nasTestpacket.GetRegistrationComplete(nil) nasPdu, err = realue_nas.EncodeNasPduWithSecurity(ue, nasPdu, nas.SecurityHeaderTypeIntegrityProtectedAndCiphered, true) @@ -161,7 +161,7 @@ func HandleRegCompleteEvent(ue *realuectx.RealUe, m := formUuMessage(common.REG_COMPLETE_EVENT, nasPdu, id) SendToSimUe(ue, m) - ue.Log.Traceln("Sent Registration Complete Message to SimUe") + ue.Log.Debugln("sent Registration Complete Message to SimUe") return nil } @@ -193,7 +193,7 @@ func HandleDeregRequestEvent(ue *realuectx.RealUe, m := formUuMessage(common.DEREG_REQUEST_UE_ORIG_EVENT, nasPdu, id) SendToSimUe(ue, m) - ue.Log.Traceln("Sent UE Initiated Deregistration Request message to SimUe") + ue.Log.Debugln("sent UE Initiated Deregistration Request message to SimUe") return nil } @@ -214,7 +214,7 @@ func HandlePduSessEstRequestEvent(ue *realuectx.RealUe, nasPdu, err = realue_nas.EncodeNasPduWithSecurity(ue, nasPdu, nas.SecurityHeaderTypeIntegrityProtectedAndCiphered, true) if err != nil { - fmt.Println("Failed to encrypt PDU Session Establishment Request Message", err) + ue.Log.Errorln("failed to encrypt PDU Session Establishment Request Message", err) return } @@ -265,7 +265,7 @@ func HandlePduSessReleaseRequestEvent(ue *realuectx.RealUe, nasPdu, err = realue_nas.EncodeNasPduWithSecurity(ue, nasPdu, nas.SecurityHeaderTypeIntegrityProtectedAndCiphered, true) if err != nil { - fmt.Println("Failed to encrypt PDU Session Release Request Message", err) + ue.Log.Errorln("failed to encrypt PDU Session Release Request Message", err) return } @@ -319,12 +319,12 @@ func HandleDataBearerSetupRequestEvent(ue *realuectx.RealUe, pdu sessions are marked failed during decoding. real ue simply returns the same list back by marking any failed pdu sessions on its side. This consolidated list can be used by gnb to form - PDUSession Resource Setup/Failed To Setup Response list + PDUSession Resource Setup/failed To Setup Response list */ if item.PduSess.Success { pduSess, err := ue.GetPduSession(item.PduSess.PduSessId) if err != nil { - ue.Log.Warnln("Failed to fetch PDU Session:", err) + ue.Log.Warnln("failed to fetch PDU Session:", err) item.PduSess.Success = false continue } @@ -410,7 +410,7 @@ func HandleDlInfoTransferEvent(ue *realuectx.RealUe, for _, pdu := range msg.NasPdus { nasMsg, err := realue_nas.NASDecode(ue, nas.GetSecurityHeaderType(pdu), pdu) if err != nil { - ue.Log.Errorln("Failed to decode dowlink NAS Message due to", err) + ue.Log.Errorln("failed to decode dowlink NAS Message due to", err) return err } msgType := nasMsg.GmmHeader.GetMessageType() @@ -483,7 +483,7 @@ func HandleServiceRequestEvent(ue *realuectx.RealUe, } func HandleNwDeregAcceptEvent(ue *realuectx.RealUe, msg common.InterfaceMessage) (err error) { - ue.Log.Traceln("Generating Dereg Accept Message") + ue.Log.Debugln("generating Dereg Accept Message") nasPdu := nasTestpacket.GetDeregistrationAccept() nasPdu, err = realue_nas.EncodeNasPduWithSecurity(ue, nasPdu, @@ -496,6 +496,6 @@ func HandleNwDeregAcceptEvent(ue *realuectx.RealUe, msg common.InterfaceMessage) m := formUuMessage(common.DEREG_ACCEPT_UE_TERM_EVENT, nasPdu, 0) SendToSimUe(ue, m) - ue.Log.Traceln("Sent Dereg Accept UE Terminated Message to SimUe") + ue.Log.Debugln("sent Dereg Accept UE Terminated Message to SimUe") return nil } diff --git a/realue/nas/nas_security.go b/realue/nas/nas_security.go index 6f57a34b..b67fda78 100644 --- a/realue/nas/nas_security.go +++ b/realue/nas/nas_security.go @@ -57,10 +57,10 @@ func GetNasPduSetupRequest(ue *realuectx.RealUe, msg *ngapType.PDUSessionResourc x := ie.Value.PDUSessionResourceSetupListSUReq for _, ie1 := range x.List { if ie1.PDUSessionNASPDU != nil { - fmt.Println("Found NAS PDU inside ResourceSEtupList") + ue.Log.Infoln("Found NAS PDU inside ResourceSEtupList") pkg := []byte(ie1.PDUSessionNASPDU.Value) m, err := NASDecode(ue, nas.GetSecurityHeaderType(pkg), pkg) - fmt.Println("UE address - ", m.GmmMessage.DLNASTransport.Ipaddr) + ue.Log.Infoln("UE address:", m.GmmMessage.DLNASTransport.Ipaddr) if err != nil { return nil } @@ -91,16 +91,16 @@ func NASEncode(ue *realuectx.RealUe, msg *nas.Message, securityContextAvailable needCiphering := false switch msg.SecurityHeader.SecurityHeaderType { case nas.SecurityHeaderTypeIntegrityProtected: - ue.Log.Debugln("Security header type: Integrity Protected") + ue.Log.Debugln("security header type: Integrity Protected") case nas.SecurityHeaderTypeIntegrityProtectedAndCiphered: - ue.Log.Debugln("Security header type: Integrity Protected And Ciphered") + ue.Log.Debugln("security header type: Integrity Protected And Ciphered") needCiphering = true case nas.SecurityHeaderTypeIntegrityProtectedWithNew5gNasSecurityContext: - ue.Log.Debugln("Security header type: Integrity Protected With New 5G Security Context") + ue.Log.Debugln("security header type: Integrity Protected With New 5G Security Context") ue.ULCount.Set(0, 0) ue.DLCount.Set(0, 0) case nas.SecurityHeaderTypeIntegrityProtectedAndCipheredWithNew5gNasSecurityContext: - ue.Log.Debugln("Security header type: Integrity Protected With New 5G Security Context") + ue.Log.Debugln("security header type: Integrity Protected With New 5G Security Context") ue.ULCount.Set(0, 0) ue.DLCount.Set(0, 0) needCiphering = true @@ -115,7 +115,7 @@ func NASEncode(ue *realuectx.RealUe, msg *nas.Message, securityContextAvailable if needCiphering { ue.Log.Debugf("Encrypt NAS message (algorithm: %+v, DLCount: 0x%0x)", ue.CipheringAlg, ue.DLCount.Get()) - ue.Log.Tracef("NAS ciphering key: %0x", ue.KnasEnc) + ue.Log.Debugf("NAS ciphering key: %0x", ue.KnasEnc) // TODO: Support for ue has nas connection in both accessType if err = security.NASEncrypt(ue.CipheringAlg, ue.KnasEnc, ue.ULCount.Get(), security.Bearer3GPP, security.DirectionUplink, payload); err != nil { @@ -183,15 +183,15 @@ func NASDecode(ue *realuectx.RealUe, securityHeaderType uint8, payload []byte) ( ciphered := false switch msg.SecurityHeaderType { case nas.SecurityHeaderTypeIntegrityProtected: - ue.Log.Debugln("Security header type: Integrity Protected") + ue.Log.Debugln("security header type: Integrity Protected") case nas.SecurityHeaderTypeIntegrityProtectedAndCiphered: - ue.Log.Debugln("Security header type: Integrity Protected And Ciphered") + ue.Log.Debugln("security header type: Integrity Protected And Ciphered") ciphered = true case nas.SecurityHeaderTypeIntegrityProtectedWithNew5gNasSecurityContext: - ue.Log.Debugln("Security Header Type Integrity Protected With New 5g Nas Security Context") + ue.Log.Debugln("security Header Type Integrity Protected With New 5g Nas Security Context") ue.DLCount.Set(0, 0) case nas.SecurityHeaderTypeIntegrityProtectedAndCipheredWithNew5gNasSecurityContext: - ue.Log.Debugln("Security header type: Integrity Protected And Ciphered With New 5G Security Context") + ue.Log.Debugln("security header type: Integrity Protected And Ciphered With New 5G Security Context") ciphered = true ue.DLCount.Set(0, 0) default: @@ -203,7 +203,7 @@ func NASDecode(ue *realuectx.RealUe, securityHeaderType uint8, payload []byte) ( } ue.DLCount.SetSQN(sequenceNumber) - ue.Log.Infof("Calculate NAS MAC (algorithm: %+v, DLCount: 0x%0x)", ue.IntegrityAlg, ue.DLCount.Get()) + ue.Log.Infof("calculate NAS MAC (algorithm: %+v, DLCount: 0x%0x)", ue.IntegrityAlg, ue.DLCount.Get()) ue.Log.Infof("NAS integrity key: %0x", ue.KnasInt) mac32, errNas := security.NASMacCalculate(ue.IntegrityAlg, ue.KnasInt, ue.DLCount.Get(), security.Bearer3GPP, diff --git a/realue/realue.go b/realue/realue.go index 767fe4e1..2046024c 100644 --- a/realue/realue.go +++ b/realue/realue.go @@ -92,6 +92,6 @@ func formUuMessage(event common.EventType, nasPdu []byte, id uint64) *common.UuM func SendToSimUe(ue *realuectx.RealUe, msg common.InterfaceMessage, ) { - ue.Log.Traceln("Sending", msg.GetEventType(), "to SimUe") + ue.Log.Debugln("sending", msg.GetEventType(), "to SimUe") ue.WriteSimUeChan <- msg } diff --git a/realue/worker/pdusessworker/handler.go b/realue/worker/pdusessworker/handler.go index 0b0c0c7b..b2e9aa0c 100644 --- a/realue/worker/pdusessworker/handler.go +++ b/realue/worker/pdusessworker/handler.go @@ -36,15 +36,15 @@ func HandleInitEvent(pduSess *realuectx.PduSession, } func SendIcmpEchoRequest(pduSess *realuectx.PduSession) (err error) { - pduSess.Log.Traceln("Sending UL ICMP ping message") + pduSess.Log.Debugln("sending UL ICMP ping message") icmpPayload, err := hex.DecodeString("8c870d0000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637") if err != nil { - pduSess.Log.Errorln("Failed to decode icmp hexString ") + pduSess.Log.Errorln("failed to decode icmp hexString ") return err } icmpPayloadLen := len(icmpPayload) - pduSess.Log.Traceln("ICMP payload size:", icmpPayloadLen) + pduSess.Log.Debugln("ICMP payload size:", icmpPayloadLen) ipv4hdr := ipv4.Header{ Version: 4, @@ -75,7 +75,7 @@ func SendIcmpEchoRequest(pduSess *realuectx.PduSession) (err error) { } b, err := icmpMsg.Marshal(nil) if err != nil { - pduSess.Log.Errorln("Failed to marshal icmp message") + pduSess.Log.Errorln("failed to marshal icmp message") return err } @@ -87,7 +87,7 @@ func SendIcmpEchoRequest(pduSess *realuectx.PduSession) (err error) { pduSess.WriteGnbChan <- userDataMsg pduSess.TxDataPktCount++ - pduSess.Log.Traceln("Sent UL ICMP ping message") + pduSess.Log.Debugln("sent UL ICMP ping message") return nil } @@ -107,7 +107,7 @@ func HandleIcmpMessage(pduSess *realuectx.PduSession, return fmt.Errorf("icmp echo reply is nil") } - pduSess.Log.Infof("Received ICMP Echo Reply, ID:%v, Seq:%v", + pduSess.Log.Infof("received ICMP Echo Reply, ID:%v, Seq:%v", echpReply.ID, echpReply.Seq) pduSess.RxDataPktCount++ @@ -121,7 +121,7 @@ func HandleIcmpMessage(pduSess *realuectx.PduSession, msg := &common.UuMessage{} msg.Event = common.DATA_PKT_GEN_SUCCESS_EVENT pduSess.WriteUeChan <- msg - pduSess.Log.Traceln("Sent Data Packet Generation Success Event") + pduSess.Log.Debugln("sent Data Packet Generation Success Event") } } default: @@ -134,10 +134,10 @@ func HandleIcmpMessage(pduSess *realuectx.PduSession, func HandleDlMessage(pduSess *realuectx.PduSession, msg common.InterfaceMessage, ) (err error) { - pduSess.Log.Traceln("Handling DL user data packet from gNb") + pduSess.Log.Debugln("handling DL user data packet from gNb") if msg.GetEventType() == common.LAST_DATA_PKT_EVENT { - pduSess.Log.Debugln("Received last downlink data packet") + pduSess.Log.Debugln("received last downlink data packet") pduSess.LastDataPktRecvd = true return nil } @@ -145,7 +145,7 @@ func HandleDlMessage(pduSess *realuectx.PduSession, dataMsg := msg.(*common.UserDataMessage) if dataMsg.Qfi != nil { - pduSess.Log.Infoln("Received QFI value in downlink user data packet:", *dataMsg.Qfi) + pduSess.Log.Infoln("received QFI value in downlink user data packet:", *dataMsg.Qfi) } ipv4Hdr, err := ipv4.ParseHeader(dataMsg.Payload) @@ -192,7 +192,7 @@ func HandleDataPktGenRequestEvent(pduSess *realuectx.PduSession, msg := &common.UuMessage{} msg.Event = common.DATA_PKT_GEN_SUCCESS_EVENT pduSess.WriteUeChan <- msg - pduSess.Log.Traceln("Sent Data Packet Generation Success Event") + pduSess.Log.Debugln("sent Data Packet Generation Success Event") }(pduSess) } return nil @@ -225,7 +225,7 @@ func HandleQuitEvent(pduSess *realuectx.PduSession, if !pduSess.LastDataPktRecvd { for pkt := range pduSess.ReadDlChan { if pkt.GetEventType() == common.LAST_DATA_PKT_EVENT { - pduSess.Log.Debugln("Received last downlink data packet") + pduSess.Log.Debugln("received last downlink data packet") break } } diff --git a/simue/context/simue.go b/simue/context/simue.go index 641ce0f0..d6a7e3b8 100644 --- a/simue/context/simue.go +++ b/simue/context/simue.go @@ -13,7 +13,7 @@ import ( profctx "github.com/omec-project/gnbsim/profile/context" realuectx "github.com/omec-project/gnbsim/realue/context" "github.com/omec-project/nas/security" - "github.com/sirupsen/logrus" + "go.uber.org/zap" ) func init() { @@ -26,7 +26,7 @@ type SimUe struct { GnB *gnbctx.GNodeB RealUe *realuectx.RealUe ProfileCtx *profctx.Profile - Log *logrus.Entry + Log *zap.SugaredLogger // SimUe writes messages to Profile routine on this channel WriteProfileChan chan *common.ProfileMessage @@ -64,9 +64,9 @@ func NewSimUe(supi string, gnb *gnbctx.GNodeB, profile *profctx.Profile, result simue.WriteRealUeChan = simue.RealUe.ReadChan simue.WriteProfileChan = result - simue.Log = logger.SimUeLog.WithField(logger.FieldSupi, supi) + simue.Log = logger.SimUeLog.With(logger.FieldSupi, supi) - simue.Log.Traceln("Created new SimUe context") + simue.Log.Debugln("created new SimUe context") simue.MsgRspReceived = make(chan bool, 5) SimUeTable[supi] = &simue return &simue diff --git a/simue/handler.go b/simue/handler.go index e7dfc1b7..d1de5c96 100644 --- a/simue/handler.go +++ b/simue/handler.go @@ -63,7 +63,7 @@ func HandleAuthRequestEvent(ue *simuectx.SimUe, ue.Log.Errorln("GetNextEvent returned:", err) return err } - ue.Log.Infoln("Next Event:", nextEvent) + ue.Log.Infoln("next event:", nextEvent) msg.Event = nextEvent SendToRealUe(ue, msg) return nil @@ -83,7 +83,7 @@ func HandleAuthResponseEvent(ue *simuectx.SimUe, msg.Event = common.UL_INFO_TRANSFER_EVENT SendToGnbUe(ue, msg) - ue.Log.Traceln("Sending Authentication Response to the network") + ue.Log.Debugln("sending Authentication Response to the network") return nil } @@ -110,7 +110,7 @@ func HandleSecModCommandEvent(ue *simuectx.SimUe, func HandleSecModCompleteEvent(ue *simuectx.SimUe, intfcMsg common.InterfaceMessage, ) (err error) { - ue.Log.Traceln("Handling Security Mode Complete Event") + ue.Log.Debugln("handling Security Mode Complete Event") msg := intfcMsg.(*common.UuMessage) err = ue.ProfileCtx.CheckCurrentEvent(ue.Procedure, common.SEC_MOD_COMMAND_EVENT, @@ -122,7 +122,7 @@ func HandleSecModCompleteEvent(ue *simuectx.SimUe, msg.Event = common.UL_INFO_TRANSFER_EVENT SendToGnbUe(ue, msg) - ue.Log.Traceln("Sent Security Mode Complete to the network") + ue.Log.Debugln("sent Security Mode Complete to the network") return nil } @@ -153,7 +153,7 @@ func HandleRegCompleteEvent(ue *simuectx.SimUe, msg.Event = common.UL_INFO_TRANSFER_EVENT SendToGnbUe(ue, msg) - ue.Log.Traceln("Sent Registration Complete to the network") + ue.Log.Debugln("sent Registration Complete to the network") // Current Procedure is complete. Move to next one SendProcedureResult(ue) @@ -166,7 +166,7 @@ func HandleDeregRequestEvent(ue *simuectx.SimUe, msg := intfcMsg.(*common.UuMessage) msg.Event = common.UL_INFO_TRANSFER_EVENT SendToGnbUe(ue, msg) - ue.Log.Traceln("Sent Deregistration Request to the network") + ue.Log.Debugln("sent Deregistration Request to the network") return nil } @@ -204,7 +204,7 @@ func HandlePduSessEstAcceptEvent(ue *simuectx.SimUe, ue.Log.Errorln("GetNextEvent returned:", err) return err } - ue.Log.Infoln("Next Event:", nextEvent) + ue.Log.Infoln("next event:", nextEvent) msg.Event = nextEvent SendToRealUe(ue, msg) return nil @@ -248,7 +248,7 @@ func HandlePduSessReleaseCommandEvent(ue *simuectx.SimUe, ue.Log.Errorln("GetNextEvent returned:", err) return err } - ue.Log.Infoln("Next Event:", nextEvent) + ue.Log.Infoln("next event:", nextEvent) msg.Event = nextEvent SendToRealUe(ue, msg) return nil @@ -311,7 +311,7 @@ func HandleDataPktGenSuccessEvent(ue *simuectx.SimUe, func HandleDataPktGenFailureEvent(ue *simuectx.SimUe, msg common.InterfaceMessage, ) (err error) { - ue.Log.Traceln("HandleDataPktGenFailureEvent") + ue.Log.Debugln("handleDataPktGenFailureEvent") SendToProfile(ue, common.PROC_FAIL_EVENT, msg.GetErrorMsg()) return nil } @@ -322,12 +322,12 @@ func retransmitMsg(ue *simuectx.SimUe, intfcMsg common.InterfaceMessage, count i for { select { case <-ue.MsgRspReceived: - ue.Log.Traceln("Received Service Accept Message ") + ue.Log.Debugln("received Service Accept Message") ticker.Stop() return case <-ticker.C: if count > 0 { - ue.Log.Traceln("Resend Service Request count ", count) + ue.Log.Debugln("resend Service Request count", count) SendToGnbUe(ue, intfcMsg) count = count - 1 } @@ -348,7 +348,7 @@ func HandleServiceRequestEvent(ue *simuectx.SimUe, go retransmitMsg(ue, intfcMsg, 2) } - ue.Log.Traceln("Sent Service Request Event to the network") + ue.Log.Debugln("sent Service Request Event to the network") return nil } @@ -394,7 +394,7 @@ func HandleConnectionReleaseRequestEvent(ue *simuectx.SimUe, ue.ReadChan <- msg */ // Nothing else to execute. Tell profile we are done. - ue.Log.Traceln("debug2") + ue.Log.Debugln("debug2") SendToProfile(ue, common.PROC_PASS_EVENT, nil) return nil } @@ -413,7 +413,7 @@ func HandleNwDeregRequestEvent(ue *simuectx.SimUe, intfcMsg common.InterfaceMess ue.Log.Errorln("GetNextEvent returned:", err) return err } - ue.Log.Infoln("Next Event:", nextEvent) + ue.Log.Infoln("next event:", nextEvent) msg.Event = nextEvent SendToRealUe(ue, msg) @@ -421,7 +421,7 @@ func HandleNwDeregRequestEvent(ue *simuectx.SimUe, intfcMsg common.InterfaceMess } func HandleNwDeregAcceptEvent(ue *simuectx.SimUe, intfcMsg common.InterfaceMessage) (err error) { - ue.Log.Traceln("Handling Dereg Accept Event") + ue.Log.Debugln("handling Dereg Accept Event") msg := intfcMsg.(*common.UuMessage) err = ue.ProfileCtx.CheckCurrentEvent(ue.Procedure, common.DEREG_REQUEST_UE_TERM_EVENT, @@ -433,14 +433,14 @@ func HandleNwDeregAcceptEvent(ue *simuectx.SimUe, intfcMsg common.InterfaceMessa msg.Event = common.UL_INFO_TRANSFER_EVENT SendToGnbUe(ue, msg) - ue.Log.Traceln("Sent Dereg Accept to the network") + ue.Log.Debugln("sent Dereg Accept to the network") return nil } func HandleErrorEvent(ue *simuectx.SimUe, intfcMsg common.InterfaceMessage, ) (err error) { - ue.Log.Traceln("debug3") + ue.Log.Debugln("debug3") SendToProfile(ue, common.PROC_FAIL_EVENT, intfcMsg.GetErrorMsg()) msg := &common.UuMessage{} @@ -467,7 +467,7 @@ func HandleQuitEvent(ue *simuectx.SimUe, // TODO : accept result, 1. pass or 2. Fail (with error) func SendProcedureResult(ue *simuectx.SimUe) { - ue.Log.Traceln("Sending Procedure Result to Profile : PASS") + ue.Log.Debugln("sending Procedure Result to Profile : PASS") SendToProfile(ue, common.PROC_PASS_EVENT, nil) // e := &stats.StatisticsEvent{Supi: ue.Supi, EType: stats.REG_PROC_END, Id: 0} // stats.LogStats(e) @@ -476,7 +476,7 @@ func SendProcedureResult(ue *simuectx.SimUe) { func HandleProcedure(ue *simuectx.SimUe) { switch ue.Procedure { case common.REGISTRATION_PROCEDURE: - ue.Log.Infoln("Initiating Registration Procedure") + ue.Log.Infoln("initiating Registration Procedure") e := &stats.StatisticsEvent{Supi: ue.Supi, EType: stats.REG_PROC_START, Id: 0} stats.LogStats(e) msg := &common.UeMessage{} @@ -484,19 +484,19 @@ func HandleProcedure(ue *simuectx.SimUe) { msg.Id = 0 SendToRealUe(ue, msg) case common.PDU_SESSION_ESTABLISHMENT_PROCEDURE: - ue.Log.Infoln("Initiating UE Requested PDU Session Establishment Procedure") + ue.Log.Infoln("initiating UE Requested PDU Session Establishment Procedure") e := &stats.StatisticsEvent{Supi: ue.Supi, EType: stats.REG_PROC_START, Id: 0} stats.LogStats(e) msg := &common.UeMessage{} msg.Event = common.PDU_SESS_EST_REQUEST_EVENT SendToRealUe(ue, msg) case common.UE_REQUESTED_PDU_SESSION_RELEASE_PROCEDURE: - ue.Log.Infoln("Initiating UE Requested PDU Session Release Procedure") + ue.Log.Infoln("initiating UE Requested PDU Session Release Procedure") msg := &common.UeMessage{} msg.Event = common.PDU_SESS_REL_REQUEST_EVENT SendToRealUe(ue, msg) case common.USER_DATA_PKT_GENERATION_PROCEDURE: - ue.Log.Infoln("Initiating User Data Packet Generation Procedure") + ue.Log.Infoln("initiating User Data Packet Generation Procedure") msg := &common.UeMessage{} msg.UserDataPktCount = ue.ProfileCtx.DataPktCount msg.UserDataPktInterval = ue.ProfileCtx.DataPktInt @@ -512,17 +512,17 @@ func HandleProcedure(ue *simuectx.SimUe) { SendToRealUe(ue, msg) case common.UE_INITIATED_DEREGISTRATION_PROCEDURE: - ue.Log.Infoln("Initiating UE Initiated Deregistration Procedure") + ue.Log.Infoln("initiating UE Initiated Deregistration Procedure") msg := &common.UeMessage{} msg.Event = common.DEREG_REQUEST_UE_ORIG_EVENT SendToRealUe(ue, msg) case common.AN_RELEASE_PROCEDURE: - ue.Log.Infoln("Initiating AN Release Procedure") + ue.Log.Infoln("initiating AN Release Procedure") msg := &common.UeMessage{} msg.Event = common.TRIGGER_AN_RELEASE_EVENT SendToGnbUe(ue, msg) case common.UE_TRIGGERED_SERVICE_REQUEST_PROCEDURE: - ue.Log.Infoln("Initiating UE Triggered Service Request Procedure") + ue.Log.Infoln("initiating UE Triggered Service Request Procedure") msg := &common.UeMessage{} msg.Event = common.SERVICE_REQUEST_EVENT SendToRealUe(ue, msg) diff --git a/simue/simue.go b/simue/simue.go index cc3bdbc5..45903058 100644 --- a/simue/simue.go +++ b/simue/simue.go @@ -27,7 +27,7 @@ func Init(simUe *simuectx.SimUe) { err := ConnectToGnb(simUe) if err != nil { err = fmt.Errorf("failed to connect to gnodeb: %v", err) - simUe.Log.Infoln("Sent Profile Fail Event to Profile routine****: ", err) + simUe.Log.Infoln("sent Profile Fail Event to Profile routine****:", err) SendToProfile(simUe, common.PROC_FAIL_EVENT, err) return } @@ -52,12 +52,12 @@ func ConnectToGnb(simUe *simuectx.SimUe) error { gNb := simUe.GnB simUe.WriteGnbUeChan, err = gnodeb.RequestConnection(gNb, &uemsg) if err != nil { - simUe.Log.Infof("ERROR -- connecting to gNodeB, Name:%v, IP:%v, Port:%v", gNb.GnbName, + simUe.Log.Errorf("connecting to gNodeB, Name:%v, IP:%v, Port:%v", gNb.GnbName, gNb.GnbN2Ip, gNb.GnbN2Port) return err } - simUe.Log.Infof("Connected to gNodeB, Name:%v, IP:%v, Port:%v", gNb.GnbName, + simUe.Log.Infof("connected to gNodeB, Name:%v, IP:%v, Port:%v", gNb.GnbName, gNb.GnbN2Ip, gNb.GnbN2Port) return nil } @@ -66,7 +66,7 @@ func HandleEvents(ue *simuectx.SimUe) { var err error for msg := range ue.ReadChan { event := msg.GetEventType() - ue.Log.Infoln("Handling event:", event) + ue.Log.Infoln("handling event:", event) switch event { case common.PROC_START_EVENT: @@ -126,7 +126,7 @@ func HandleEvents(ue *simuectx.SimUe) { case common.DEREG_ACCEPT_UE_TERM_EVENT: err = HandleNwDeregAcceptEvent(ue, msg) case common.ERROR_EVENT: - ue.Log.Warnln("Event:", event, " received error") + ue.Log.Warnln("event:", event, " received error") err = HandleErrorEvent(ue, msg) if err != nil { ue.Log.Warnln("failed to handle error event:", err) @@ -139,11 +139,11 @@ func HandleEvents(ue *simuectx.SimUe) { } return default: - ue.Log.Warnln("Event:", event, "is not supported") + ue.Log.Warnln("event:", event, "is not supported") } if err != nil { - ue.Log.Errorln("Failed to handle event:", event, "Error:", err) + ue.Log.Errorln("failed to handle event:", event, "Error:", err) msg := &common.UeMessage{} msg.Error = err msg.Event = common.ERROR_EVENT @@ -157,24 +157,24 @@ func HandleEvents(ue *simuectx.SimUe) { } func SendToRealUe(ue *simuectx.SimUe, msg common.InterfaceMessage) { - ue.Log.Traceln("Sending", msg.GetEventType(), "to RealUe") + ue.Log.Debugln("sending", msg.GetEventType(), "to RealUe") ue.WriteRealUeChan <- msg } func SendToGnbUe(ue *simuectx.SimUe, msg common.InterfaceMessage) { - ue.Log.Traceln("Sending", msg.GetEventType(), "to GnbUe") + ue.Log.Debugln("sending", msg.GetEventType(), "to GnbUe") ue.WriteGnbUeChan <- msg } func SendToProfile(ue *simuectx.SimUe, event common.EventType, errMsg error) { - ue.Log.Traceln("Sending", event, "to Profile routine") + ue.Log.Debugln("sending", event, "to Profile routine") msg := &common.ProfileMessage{} msg.Event = event msg.Supi = ue.Supi msg.Proc = ue.Procedure msg.Error = errMsg ue.WriteProfileChan <- msg - ue.Log.Traceln("Sent ", event, "to Profile routine") + ue.Log.Debugln("sent ", event, "to Profile routine") } func RunProcedure(simUe *simuectx.SimUe, procedure common.ProcedureType) { @@ -193,7 +193,7 @@ func ImsiStateMachine(profile *profctx.Profile, pCtx *profctx.ProfileUeContext, //if simUe == nil { // pass readChan to simUe //} - pCtx.Log.Infoln("Execute procedure ", procedure) + pCtx.Log.Infoln("execute procedure ", procedure) // proc result - success, fail or timeout timeout := time.Duration(profile.PerUserTimeout) * time.Second ticker := time.NewTicker(timeout) diff --git a/util/test/gtp.go b/util/test/gtp.go index 8cb835bb..158212b8 100644 --- a/util/test/gtp.go +++ b/util/test/gtp.go @@ -134,14 +134,14 @@ func DecodeGTPv1Header(pkt []byte) (gtpPdu *GtpPdu, err error) { return nil, err } - logger.GtpLog.Traceln("Header field - Length:", gtpPdu.Hdr.Len) - logger.GtpLog.Traceln("Header field - TEID:", gtpPdu.Hdr.Teid) + logger.GtpLog.Debugln("header field - Length:", gtpPdu.Hdr.Len) + logger.GtpLog.Debugln("header field - TEID:", gtpPdu.Hdr.Teid) payloadStart := GTPU_HEADER_LENGTH payloadEnd := gtpPdu.Hdr.Len + GTPU_HEADER_LENGTH if (gtpPdu.Hdr.Flags & FLAG_OPTIONAL) != 0 { - logger.GtpLog.Traceln("Optional header present") + logger.GtpLog.Debugln("optional header present") gtpPdu.OptHdr = &GtpHdrOpt{} err = binary.Read(buf, binary.BigEndian, gtpPdu.OptHdr) if err != nil {