+0
日增长
298
stars
195
forks
32
watchers
151
prs
126
issues
6
releases
README
Diameter Base Protocol Package go-diameter is an implementation of the Diameter Base Protocol RFC 6733 and a stack for the Go programming language. Status The current implementation is solid and works fine for general purpose clients and servers. It can send and receive messages efficiently as well as build and parse AVPs based on dictionaries. See the API documentation at https://pkg.go.dev/github.com/fiorix/go-diameter/v4 Features - Comprehensive XML dictionary format - Embedded dictionaries: Base Protocol RFC 6733 Credit Control RFC 4006 Gx Credit Control Network Access Server RFC 7155 3GPP Ro/Rf specific AVPs from TS 32.299 version 12.7.0 3GPP S6a specific commands and AVPs from RFC 5516 and TS 129 272 3GPP S13 (EIR) ME-Identity-Check commands and AVPs 3GPP Rx policy and charging control 3GPP SWx commands and AVPs Diameter Sy policy control - Human readable AVP representation (for debugging) - TLS, IPv4 and IPv6 support for both clients and servers - Stack based on net/http for simplicity - Ships with sample client, server, snoop agent and benchmark tool - State machines for CER/CEA and DWR/DWA for clients and servers - TCP and SCTP support. SCTP support relies on kernel SCTP implementation and external github.com/ishidawataru/sctp package and is currently tested and enabled on Linux (Go 1.26 or later) Getting started The easiest way to get started is by trying out the client and server example programs. go run github.com/fiorix/go-diameter/v4/examples/server@latest go run github.com/fiorix/go-diameter/v4/examples/client@latest -hello See the other programs under examples/ and the package test files for additional usage patterns. Performance Throughput is sensitive to how clients and servers are structured. The package ships Go benchmarks plus a standalone benchmark tool for exercising servers and identifying bottlenecks. In the examples directory, the server has a pprof (http server) that allows the go pprof tool to profile the server in real time. The client can perform benchmarks using the -bench command line flag. For better performance, avoid logging diameter messages. Although logging is very useful for debugging purposes, it kills performance due to a number of conversions to make messages look pretty. If you run benchmarks on the example server, make sure to use the -s (silent) command line switch. TLS degrades performance a bit, as well as reflection (Unmarshal). Those are important trade offs you might have to consider. Besides this, the source code (and sub-packages) have function benchmarks that can help you understand what's fast and isn't. You will see that parsing messages is much slower than writing them, for example. This is because in order to parse messages it makes numerous dictionary lookups for AVP types, to be able to decode them. Encoding messages require less lookups and is generally simpler, thus faster. Contribute In case you want
Top issues
#277dict: register AVPs at runtime, before a Parser serves traffic0 comments · 2026-10-31#248Dynamic Dictionaries and other production features0 comments · 2026-05-12
Latest release
v4.6.0 v4.6.0 2026-10-31Behavior changes - A message whose Application-Id and Command-Code are not in the dictionary no longer fails ReadMessage and no longer closes the connection. It decodes generically and reaches the ALL handler if one is registered, otherwise ErrorReports. This applies with Strict set as well; Strict still governs AVP-level decode errors. AVPs on an application the dictionary does not know decode as datatype.Unknown, so this is not typed support for such applications (for example Cx/Dx). Thanks to @towi for the fix and the reproduction, and to @volkland. (257) - A write error on a TCP or TLS co