feat(n3iwf): add N3IWF-ID support alongside GNB-ID#226
Draft
andybavier wants to merge 5 commits intomainfrom
Draft
feat(n3iwf): add N3IWF-ID support alongside GNB-ID#226andybavier wants to merge 5 commits intomainfrom
andybavier wants to merge 5 commits intomainfrom
Conversation
Extends the sctplb protobuf contract and runtime to support N3IWF (Non-3GPP Interworking Function) nodes in addition to gNBs. N3IWF nodes connect to the AMF via the same N2/NGAP/SCTP path but carry a distinct N3IWF-ID identifier. Changes: - client.proto: add N3iwfId field (SctplbMessage field 7, AmfMessage field 8) and N3IWF_MSG/N3IWF_DISC/N3IWF_CONN msgType values - sdcoreAmfServer: regenerate pb.go files from updated proto - context: add N3iwfId field to Ran, SetN3iwfId(), RanFindByN3iwfId(), and update RanID() to format N3IWF identity correctly - backend/grpc.go: Send() uses N3IWF_MSG/N3IWF_DISC for N3IWF RANs; readFromServer() routes by N3iwfId and propagates it in REDIRECT_MSG; ConnectToServer() INIT loop sends N3iwfId for N3IWF RANs Closes #225. Requires coordinated AMF update to populate N3iwfId in AmfMessage responses for N3IWF NGSetup flows. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Andy Bavier <andybavier@gmail.com>
- Extract repeated "Hello From gNB Message !" to verboseGnbMsg constant - Reformat context_test.go to satisfy gci formatter 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Andy Bavier <andybavier@gmail.com>
f5ff20f to
7741487
Compare
Signed-off-by: Andy Bavier <andybavier@gmail.com>
There was a problem hiding this comment.
Pull request overview
Adds N3IWF-ID support to sctplb so it can track and route N3IWF-associated NGAP traffic alongside existing gNB-ID routing, including proto/schema updates and corresponding context + gRPC backend routing changes.
Changes:
- Extend
client.proto(and generated Go bindings) withN3iwfIdfields and newN3IWF_*message types. - Add
N3iwfIdstorage + lookup (SetN3iwfId,RanFindByN3iwfId) and updateRanID()formatting/precedence. - Update gRPC backend send/receive paths to bind and route by
N3iwfIdwhen present, with added unit tests for context changes.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
client.proto |
Adds N3iwfId fields and N3IWF msg types to the API schema. |
sdcoreAmfServer/client.pb.go |
Regenerates Go protobuf types for new fields/enums. |
sdcoreAmfServer/client_grpc.pb.go |
Regenerates Go gRPC stubs for the updated proto. |
context/context.go |
Extends Ran context with N3iwfId, adds setter/lookup, updates RanID(). |
context/context_test.go |
Adds unit tests covering new context behaviors. |
backend/grpc.go |
Routes/binds using N3iwfId when present; updates Send/readFromServer/ConnectToServer paths. |
Comments suppressed due to low confidence (1)
backend/grpc.go:63
- The log says the RAN details are "not sending" when neither RanId nor N3iwfId is set, but the code still calls stream.Send(&req) (and then waits on stream.Recv()). This can send INIT messages with no identifier and can also block on Recv unnecessarily. Consider skipping the send/recv for this candidate (e.g., return early from the Range callback) when both IDs are absent.
if candidate.N3iwfId != nil {
req.N3IwfId = *candidate.N3iwfId
} else if candidate.RanId != nil {
req.GnbId = *candidate.RanId
} else {
logger.AppLog.Infof("ran connection %v exists without RanId or N3iwfId, so not sending this ran details to NF",
candidate.GnbIp)
}
if err := stream.Send(&req); err != nil {
logger.AppLog.Warnln("can not send:", err)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- context.go: RanFindByGnbId now skips candidates with nil RanId, preventing a panic when N3IWF RANs (RanId == nil) are in RanPool - backend/grpc.go: REDIRECT_MSG forwarding now uses MsgType_N3IWF_MSG and N3IwfId when response.N3IwfId is set, instead of always labelling as GNB_MSG Addresses PR review comments. Signed-off-by: Andy Bavier <andybavier@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
client.protowithN3iwfIdfield (backward-compatible addition) andN3IWF_MSG/N3IWF_DISC/N3IWF_CONNmessage typesN3iwfIdfield andSetN3iwfId/RanFindByN3iwfIdto theRancontext so N3IWF connections are tracked alongside gNBsbackend/grpc.go(Send,readFromServer,ConnectToServer) to route messages usingN3iwfIdwhen presentCloses #225.
Note: Requires a coordinated update to
omec-project/amfto populateN3iwfIdinAmfMessageresponses for N3IWF NGSetup flows. The proto change is backward-compatible — old AMF deployments leaveN3iwfIdempty and all existing gNB paths are unaffected.Testing
context/context_test.gowith tests forSetN3iwfId,RanFindByN3iwfId, and the updatedRanID()formatting (9 subtests, all pass)Post-Deploy Monitoring & Validation
received N3iwfId: <id> for GnbIpAddress: <ip> from NF— confirms AMF is populating the new field for N3IWF connectionscouldn't fetch sctp connectionlog lines — indicates AMF side has not yet been updatedN3iwfIdfield will be empty and all gNB routing is unaffected