Skip to content

feat(n3iwf): add N3IWF-ID support alongside GNB-ID#226

Draft
andybavier wants to merge 5 commits intomainfrom
feat/n3iwf-id-support
Draft

feat(n3iwf): add N3IWF-ID support alongside GNB-ID#226
andybavier wants to merge 5 commits intomainfrom
feat/n3iwf-id-support

Conversation

@andybavier
Copy link
Copy Markdown

@andybavier andybavier commented Mar 19, 2026

Summary

  • Extends client.proto with N3iwfId field (backward-compatible addition) and N3IWF_MSG/N3IWF_DISC/N3IWF_CONN message types
  • Adds N3iwfId field and SetN3iwfId/RanFindByN3iwfId to the Ran context so N3IWF connections are tracked alongside gNBs
  • Updates backend/grpc.go (Send, readFromServer, ConnectToServer) to route messages using N3iwfId when present

Closes #225.

Note: Requires a coordinated update to omec-project/amf to populate N3iwfId in AmfMessage responses for N3IWF NGSetup flows. The proto change is backward-compatible — old AMF deployments leave N3iwfId empty and all existing gNB paths are unaffected.

Testing

  • Added context/context_test.go with tests for SetN3iwfId, RanFindByN3iwfId, and the updated RanID() formatting (9 subtests, all pass)

Post-Deploy Monitoring & Validation

  • Logs to watch: received N3iwfId: <id> for GnbIpAddress: <ip> from NF — confirms AMF is populating the new field for N3IWF connections
  • Failure signal: N3IWF NGAP messages result in couldn't fetch sctp connection log lines — indicates AMF side has not yet been updated
  • Rollback: sctplb is safe to deploy first; with an old AMF the N3iwfId field will be empty and all gNB routing is unaffected
  • Validation window: After AMF update is deployed, verify N3IWF NGSetup completes end-to-end

Compound Engineered 🤖 Generated with Claude Code

@andybavier andybavier requested a review from a team March 19, 2026 20:46
@andybavier andybavier marked this pull request as draft March 19, 2026 20:47
andybavier and others added 2 commits March 19, 2026 13:47
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>
@andybavier andybavier force-pushed the feat/n3iwf-id-support branch from f5ff20f to 7741487 Compare March 19, 2026 20:54
Signed-off-by: Andy Bavier <andybavier@gmail.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) with N3iwfId fields and new N3IWF_* message types.
  • Add N3iwfId storage + lookup (SetN3iwfId, RanFindByN3iwfId) and update RanID() formatting/precedence.
  • Update gRPC backend send/receive paths to bind and route by N3iwfId when 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.

Comment thread context/context.go
Comment thread backend/grpc.go Outdated
- 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable support for n3iwf-id

2 participants