Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Handover; close #23 #24

Merged
merged 2 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions jsonapi/control_uri.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ type ControlURI struct {
}

func (u *ControlURI) UnmarshalText(text []byte) error {
if len(text) == 0 {
return fmt.Errorf("Control URI should not be empty.")
}
if text[len(text)-1] == '/' {
return fmt.Errorf("Control URI should not contains trailing slash.")
}
Expand Down
20 changes: 20 additions & 0 deletions jsonapi/fteid.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2024 Louis Royer and the NextMN contributors. All rights reserved.
// Use of this source code is governed by a MIT-style license that can be
// found in the LICENSE file.
// SPDX-License-Identifier: MIT

package jsonapi

import "net/netip"

type Fteid struct {
Addr netip.Addr `json:"addr"`
Teid uint32 `json:"teid"`
}

func NewFteid(addr netip.Addr, teid uint32) *Fteid {
return &Fteid{
Addr: addr,
Teid: teid,
}
}
22 changes: 22 additions & 0 deletions jsonapi/n1n2/handover_command.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2024 Louis Royer and the NextMN contributors. All rights reserved.
// Use of this source code is governed by a MIT-style license that can be
// found in the LICENSE file.
// SPDX-License-Identifier: MIT

package n1n2

import (
"github.com/nextmn/json-api/jsonapi"
)

// HandoverCommand is sent by the CP to the source gNB to start the execution of handover, and forwarded to the UE
type HandoverCommand struct {
// Header
UeCtrl jsonapi.ControlURI `json:"ue-ctrl"`
Cp jsonapi.ControlURI `json:"cp"`
SourceGnb jsonapi.ControlURI `json:"source-gnb"`

// Handover Command
Sessions []Session `json:"sessions"` // contains new ForwardDownlinkFteid
TargetGnb jsonapi.ControlURI `json:"target-gnb"`
}
22 changes: 22 additions & 0 deletions jsonapi/n1n2/handover_confirm.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2024 Louis Royer and the NextMN contributors. All rights reserved.
// Use of this source code is governed by a MIT-style license that can be
// found in the LICENSE file.
// SPDX-License-Identifier: MIT

package n1n2

import (
"github.com/nextmn/json-api/jsonapi"
)

// HandoverConfirm is send by the target UE to the target gNB after the UE is synchronized to the new cell
type HandoverConfirm struct {
// Header
UeCtrl jsonapi.ControlURI `json:"ue-ctrl"`
Cp jsonapi.ControlURI `json:"cp"`

// Handover Confirm
Sessions []Session `json:"sessions"`
SourceGnb jsonapi.ControlURI `json:"source-gnb"`
TargetGnb jsonapi.ControlURI `json:"target-gnb"`
}
22 changes: 22 additions & 0 deletions jsonapi/n1n2/handover_notify.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2024 Louis Royer and the NextMN contributors. All rights reserved.
// Use of this source code is governed by a MIT-style license that can be
// found in the LICENSE file.
// SPDX-License-Identifier: MIT

package n1n2

import (
"github.com/nextmn/json-api/jsonapi"
)

// HandoverNotify is send by the target gNB to the CP after handover have been confirmed by the UE
type HandoverNotify struct {
// Header
UeCtrl jsonapi.ControlURI `json:"ue-ctrl"`
Cp jsonapi.ControlURI `json:"cp"`
TargetGnb jsonapi.ControlURI `json:"target-gnb"`

// Handover Notify
Sessions []Session `json:"sessions"`
SourceGnb jsonapi.ControlURI `json:"source-gnb"`
}
22 changes: 22 additions & 0 deletions jsonapi/n1n2/handover_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2024 Louis Royer and the NextMN contributors. All rights reserved.
// Use of this source code is governed by a MIT-style license that can be
// found in the LICENSE file.
// SPDX-License-Identifier: MIT

package n1n2

import (
"github.com/nextmn/json-api/jsonapi"
)

// HandoverRequest is send by the CP to the target gNB during the handover preparation phase
type HandoverRequest struct {
// Header
UeCtrl jsonapi.ControlURI `json:"ue-ctrl"`
Cp jsonapi.ControlURI `json:"cp"`
TargetgNB jsonapi.ControlURI `json:"target-gnb"`

// Handover Request
SourcegNB jsonapi.ControlURI `json:"source-gnb"`
Sessions []Session `json:"sessions"` // contains new UL FTeid
}
22 changes: 22 additions & 0 deletions jsonapi/n1n2/handover_request_ack.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2024 Louis Royer and the NextMN contributors. All rights reserved.
// Use of this source code is governed by a MIT-style license that can be
// found in the LICENSE file.
// SPDX-License-Identifier: MIT

package n1n2

import (
"github.com/nextmn/json-api/jsonapi"
)

// HandoverRequestAck is send by the target gNB to the CP in response to an HandoverRequest
type HandoverRequestAck struct {
// Header
Cp jsonapi.ControlURI `json:"cp"`
TargetgNB jsonapi.ControlURI `json:"target-gnb"`

// Handover Request Ack
SourcegNB jsonapi.ControlURI `json:"source-gnb"`
UeCtrl jsonapi.ControlURI `json:"ue-ctrl"`
Sessions []Session `json:"sessions"` // contains new DL FTeid
}
22 changes: 22 additions & 0 deletions jsonapi/n1n2/handover_required.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2024 Louis Royer and the NextMN contributors. All rights reserved.
// Use of this source code is governed by a MIT-style license that can be
// found in the LICENSE file.
// SPDX-License-Identifier: MIT

package n1n2

import (
"github.com/nextmn/json-api/jsonapi"
)

// HandoverRequired is send by the source gNB to the CP to start the handover preparation phase
type HandoverRequired struct {
// Header
SourcegNB jsonapi.ControlURI `json:"source-gnb"`
Cp jsonapi.ControlURI `json:"cp"`

// Handover Required content
Ue jsonapi.ControlURI `json:"ue"`
Sessions []Session `json:"sessions"` // list of all pdu sessions of the UE to be moved
TargetgNB jsonapi.ControlURI `json:"target-gnb"`
}
5 changes: 1 addition & 4 deletions jsonapi/n1n2/n2_pdu_session_req_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
package n1n2

import (
"net/netip"

"github.com/nextmn/json-api/jsonapi"
)

Expand All @@ -17,6 +15,5 @@ type N2PduSessionReqMsg struct {
UeInfo PduSessionEstabAcceptMsg `json:"ue-info"` // information to forward to the UE

// Uplink FTEID: the gNB will establish an Uplink GTP Tunnel using the following
Upf netip.Addr `json:"upf"`
UplinkTeid uint32 `json:"uplink-teid"`
UplinkFteid jsonapi.Fteid `json:"uplink-fteid"`
}
7 changes: 4 additions & 3 deletions jsonapi/n1n2/n2_pdu_session_resp_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@

package n1n2

import "net/netip"
import (
"github.com/nextmn/json-api/jsonapi"
)

// N2PduSessionRespMsg is sent to the CP by the gNB as a response of N2PduSessionReqMsg.
type N2PduSessionRespMsg struct {
UeInfo PduSessionEstabAcceptMsg `json:"ue-info"` // used to identify the PDU Session

// Downlink FTEID: the CP will use this to configure a downlink GTP Tunnel in Upf-i
DownlinkTeid uint32 `json:"downlink-teid"`
Gnb netip.Addr `json:"gnb"`
DownlinkFteid jsonapi.Fteid `json:"downlink-fteid"`
}
File renamed without changes.
23 changes: 23 additions & 0 deletions jsonapi/n1n2/session.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2024 Louis Royer and the NextMN contributors. All rights reserved.
// Use of this source code is governed by a MIT-style license that can be
// found in the LICENSE file.
// SPDX-License-Identifier: MIT

package n1n2

import (
"net/netip"

"github.com/nextmn/json-api/jsonapi"
)

type Session struct {
Addr netip.Addr `json:"ue-addr"`
Dnn string `json:"dnn"`
UplinkFteid *jsonapi.Fteid `json:"uplink-fteid,omitempty"`
DownlinkFteid *jsonapi.Fteid `json:"downlink-fteid,omitempty"`

// when ForwardDownlinkFteid is not empty,
// PDUs received on DownlinkFteid must be forwarded to it
ForwardDownlinkFteid *jsonapi.Fteid `json:"forward-fteid,omitempty"`
}
28 changes: 28 additions & 0 deletions jsonapi_test/n1n2_test/session_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2024 Louis Royer and the NextMN contributors. All rights reserved.
// Use of this source code is governed by a MIT-style license that can be
// found in the LICENSE file.
// SPDX-License-Identifier: MIT

package n1n2_test

import (
"encoding/json"
"testing"

"github.com/nextmn/json-api/jsonapi/n1n2"
)

func TestSession(t *testing.T) {
s := &n1n2.Session{}
if err := json.Unmarshal([]byte("{\"ue-addr\": \"127.0.0.1\", \"uplink-fteid\": {\"addr\": \"127.0.0.2\", \"teid\": 80}}"), s); err != nil {
t.Errorf("Session with only uplink FTeid could not be unmarshaled")
}

if s.DownlinkFteid != nil {
t.Errorf("Downlink Fteid was not defined but is not nil")
}
if s.UplinkFteid == nil {
t.Errorf("Uplink Fteid was defined but is nil")
}

}
Loading