Skip to content

Go library

OT Fabric splits IEC 61850 over two Go libraries. Both are pure Go with no CGO, MIT-licensed, and have a stable v1 API.

go-iec61850 go-mms
Speaks IEC 61850 over MMS, GOOSE and Sampled Values, on Ethernet and routable over UDP (LD, LN, DO, DA, FC, datasets, RCBs, GoCBs, MSVCBs, controls, SCL) Generic MMS, ISO 9506 (domains, item IDs, named variable lists)
Version described here v1.19.4 v1.9.2
Go version 1.26 or later 1.26 or later
Client Yes Yes
Server SCL-driven, with reports, controls, setting groups, journals, GOOSE and SV Yes, you register domains and variables
Use it when You talk to IEDs, listen to or publish on the station bus, or simulate an IED. This is the right choice almost always. You need raw MMS: a non-IEC 61850 MMS device, alternate access, wire-level tests, or a custom transport.

go-iec61850 is one module with these packages:

Package Contents
iec61850 MMS client and server, reports, controls, datasets, setting groups, journals, files, GoCB and MSVCB engines
goose GOOSE frame codec, publisher, subscriber, SCL binding
sv Sampled Values frame codec, 9-2LE layout, publisher, subscriber, SCL binding
l2 Raw Ethernet shared by goose and sv: AF_PACKET, BPF, EtherType demultiplexing and an in-memory hub
rsession R-GOOSE and R-SV: the session protocol of IEC TR 61850-90-5 over UDP, with HMAC-SHA256 authentication, as a transport for goose and sv
scl, scl/index, scl/validate SCL parsing, cross-reference index and semantic validation

The MMS side is built on go-mms, and go-mms uses go-cotp (v1.3.0; separate read and write deadlines since v1.1.0) and go-tpkt for the transport. You can always reach the lower layer: Client.MMS() returns the underlying *mms.Client.

Terminal window
go get github.com/otfabric/go-iec61850 # Go 1.26+
go get github.com/otfabric/go-mms # Go 1.26+, pulled in automatically by go-iec61850

This page follows go-iec61850 v1.19.4 and go-mms v1.9.2.

iec61850.Dial opens TCP, runs the COTP, session, presentation, ACSE and MMS Initiate exchange, and returns a *Client. Port 102 is the standard MMS port.

main.go
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/otfabric/go-iec61850"
)
func main() {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
client, err := iec61850.Dial(ctx, "10.0.0.1:102", iec61850.DialOptions{})
if err != nil {
log.Fatal(err)
}
defer client.Close(context.Background())
devices, err := client.ListLogicalDevices(ctx)
if err != nil {
log.Fatal(err)
}
for _, ld := range devices {
fmt.Println(ld.Name)
}
ref, _ := iec61850.ParseRef("PROT1LD/MMXU1.TotW.mag.f[MX]")
val, err := client.Read(ctx, ref)
if err != nil {
log.Fatal(err)
}
fmt.Println(val)
}

DialOptions fields:

Field Purpose
MMS mms.DialOptions: ISO selectors and AP titles, ACSE password, MMS MaxPDUSize (default 65000), raw wire hook.
MaxTPDULength The COTP TPDU size proposed in the connection request (default 1024; 65531 omits it).
Logger *slog.Logger. Also passed to the MMS layer when MMS.Logger is nil.
IEDName Prepended to outgoing domain names and stripped from returned names, so your code uses bare LD names on servers that prefix domains with the IED name.
Cache CacheNone (default), CacheExplicit (filled by RefreshCache) or CacheLazy (filled on first access per LD). In memory only.
Strictness RejectUnknownFC, VerifyReportCandidates.
Retry mms.RetryPolicy for TCP connect, COTP and association, with exponential backoff and jitter. The zero value tries once; mms.DefaultRetryPolicy() is a sensible reconnect policy. Errors a retry cannot fix return at once.
Metrics An mms.Metrics that observes every request and connection event.
Dialer Opens the TCP connection, for a destination allowlist checked against the resolved IP, a proxy, socket options or an in-memory transport. Nil keeps the default net.Dialer. TLS goes through go-mms iso.Dial (below).
Clock Stamps the T of Operate, SelectWithValue and Cancel, with its TimeQuality (see Time and TimeQuality).

ISO addressing. Since go-iec61850 v1.6.0 (go-mms v1.4.0) a client sends the addressing libiec61850 sends, which IEDs that require transport selectors expect: T-selector 0001 and TPDU size 1024 in the COTP CR, S-selector 0001, P-selector 00000001, AP-titles 1.1.1.999 and 1.1.1.999.1, AE-qualifier 12. Before, every selector was left out and such an IED refused the connection (“cotp: connection refused (reason 3)”). For an IED configured otherwise, take the values from its SCL ConnectedAP with ApplySCLAddress(&opts.MMS, ap), or parse them with ParseSelector and ParseAPTitle. A non-nil empty value omits a parameter again, and a T-selector longer than 4 octets is refused before dialing.

Per-request timeouts are set with MMS.RequestTimeout. Client.MMS().Done() and Err() tell you when and why the association ended.

Close sends MMS Conclude. Abort drops the association immediately; use it for servers that do not answer Conclude (IEC61850bean is one).

Through a go-mms client (TLS, custom ISO parameters)

Section titled “Through a go-mms client (TLS, custom ISO parameters)”

When you need ISO-level options, dial with go-mms and wrap the result with iec61850.NewClient. The transport/iso package wires TPKT and COTP together and also offers iso.WithTLSConfig for TLS over TCP and iso.WithLogger for ISO-layer logging.

import (
mms "github.com/otfabric/go-mms"
"github.com/otfabric/go-mms/transport/iso"
"github.com/otfabric/go-iec61850"
)
mmsClient, err := iso.Dial(ctx, "10.0.0.1:102",
iso.WithClientDialOptions(mms.DialOptions{
MMS: mms.MMSOptions{MaxPDUSize: 65000},
}),
)
if err != nil {
log.Fatal(err)
}
client, err := iec61850.NewClient(mmsClient, iec61850.ClientOptions{IEDName: "InteropIED"})

For tests or unusual links, implement the mms.Transport interface (Read, Write, Close) and pass it to mms.NewClient.

lns, _ := client.ListLogicalNodes(ctx, "InteropLD")
dos, _ := client.ListDataObjects(ctx, "InteropLD", "GGIO1")
root, err := client.TreeWithOptions(ctx, iec61850.TreeOptions{
LDFilter: "InteropLD",
IncludeFCs: true,
})
refs, err := client.FindPaths(ctx, iec61850.FindQuery{
Pattern: "*MMXU*",
MatchMode: iec61850.MatchGlob,
FC: iec61850.FCMX,
})

Tree walks the whole server and can be slow on large IEDs; scope it with LDFilter and MaxDepth. GetVariableType returns the MMS type spec for one reference.

ParseRef accepts LD/LN.DO.DA[FC]. Ref.ToMMS() and RefFromMMS() convert to and from the MMS domain and LN$FC$DO$DA item ID.

ref, _ := iec61850.ParseRef("IEDLD1/LLN0.Mod.stVal[ST]")
fmt.Println(ref.LD, ref.LN, ref.Path, ref.FC) // IEDLD1 LLN0 [Mod stVal] ST

Read returns an *iec61850.Value with typed accessors. There is no automatic coercion: calling Int64() on a FLOAT32 returns an error.

qRef, _ := iec61850.ParseRef("InteropLD/GGIO1.SPS1.q[ST]")
qv, err := client.Read(ctx, qRef)
if err != nil {
log.Fatal(err)
}
q, err := qv.Quality()
if err == nil && !q.IsGood() {
log.Printf("validity=%v flags=%s", q.Validity(), q)
}

ReadMultiple reads many references in one MMS PDU and returns a ReadResult per reference with its own Err. ReadComponent reads one component of a structure.

Write takes an *mms.Value:

ref, _ := iec61850.ParseRef("InteropLD/GGIO1.SetInt1.setVal[SP]")
if err := client.Write(ctx, ref, mms.NewInteger(5)); err != nil {
log.Fatal(err)
}
names, _ := client.ListDataSets(ctx, "InteropLD")
ds, _ := client.GetDataSet(ctx, "InteropLD", names[0]) // ds.Members lists the FCDAs
values, err := client.ReadDataSet(ctx, "InteropLD", names[0])
for _, v := range values {
if v.Err != nil {
continue
}
fmt.Println(v.Member.Ref, v.Value)
}

Use the dataset names exactly as ListDataSets returns them. CreateDataSet and DeleteDataSet work as a client against servers that allow dynamic datasets. The go-iec61850 server does not implement dynamic dataset creation or deletion.

SubscribeReport handles the RCB lifecycle: optional URCB reservation, enable, optional general interrogation, delivery on a channel, and disable on Close.

reports, _ := client.ListReports(ctx, ld)
rcb, err := client.GetReportControlBlock(ctx, ld, reports[0])
if err != nil {
log.Fatal(err)
}
sub, err := client.SubscribeReport(ctx, rcb.RptID, iec61850.SubscribeReportOptions{
QueueSize: 64,
OverflowPolicy: iec61850.OverflowDropNewest,
AutoEnable: true,
GIOnSubscribe: true,
ReserveURCB: rcb.Type == iec61850.RCBUnbuffered,
LD: ld,
RCBItemID: reports[0],
})
if err != nil {
log.Fatal(err)
}
defer sub.Close()
for ri := range sub.Reports() {
fmt.Printf("RptID=%s SeqNum=%d reasons=%v\n", ri.RptID, ri.SeqNum, ri.ReasonCodes)
for i, v := range ri.Values {
fmt.Printf(" [%d] %s\n", i, v)
}
}

Each ReportIndication carries SeqNum, EntryID, BufOvfl, Inclusion, DataReferences, Values and ReasonCodes. Segmented reports are reassembled for you.

The client queue defaults to 64. When it fills, OverflowPolicy decides: OverflowDropNewest (default), OverflowDropOldest, OverflowBlock (no loss, but stalls all report delivery) or OverflowCallback (calls OnOverflow). The server never learns about client-side drops.

To configure an RCB yourself, SetReportControlBlock writes only the fields named in the mask. For a BRCB, write the last EntryID you received before enabling to resume, or set PurgeBuf to start clean:

err := client.SetReportControlBlock(ctx, ld, rcbItemID, iec61850.RCBUpdate{
Fields: iec61850.RCBFieldEntryID,
EntryID: lastEntryID, // 8 bytes; entries strictly after this one are replayed
})

TriggerGI, ReserveURCB and ReleaseURCB are also available. EntryIDs from the go-iec61850 server reset on restart and after a purge, so do not cache them across server restarts.

ref, _ := iec61850.ParseRef("InteropLD/GGIO1.SPCSO2")
ref.FC = "" // control APIs manage the FC
model, err := client.ReadCtlModel(ctx, ref)
if err != nil || !model.IsControllable() {
log.Fatalf("not controllable: %v %v", model, err)
}
params := iec61850.OperateParams{CtlVal: iec61850.BoolCtlVal(true)}
switch {
case model.IsSBO() && model.IsEnhanced(): // SBOw
err = client.SelectWithValue(ctx, ref, params)
case model.IsSBO(): // SBO normal
_, err = client.Select(ctx, ref)
}
if err == nil {
err = client.Operate(ctx, ref, params)
}
if err != nil {
if lae, lerr := client.ReadLastApplError(ctx, ref); lerr == nil {
log.Printf("rejected: addCause=%s", lae.AddCause)
}
}

OperateParams also takes Origin (OrCat, OrIdent), CtlNum, OperTm (a time-activated operate), Test and Check (synchrocheck, interlock check). Use the same CtlNum for SelectWithValue and Operate. Cancel releases a selection. Value helpers: BoolCtlVal, IntCtlVal, FloatCtlVal, EnumCtlVal, StringCtlVal, BspCtlVal, DpCtlVal.

With enhanced security, OperateWait operates and waits for the CommandTermination; a negative termination returns a ControlError wrapping ErrCommandTerminationNegative, with the AddCause and LastApplError the server reported. A refused Operate, SelectWithValue or Cancel carries the LastApplError the server sent in its ControlError, so ReadLastApplError is deprecated.

The client also covers setting groups (GetSettingGroupInfo, SelectActiveSG, SelectEditSG, SetEditSGValue, ConfirmEditSG), journals (ListJournals, ReadJournal, ReadJournalAfter, and the auto-paginating ReadJournalAll / ReadJournalAfterAll) and files (ListFiles, ReadFile, DownloadFile, DeleteFile, RenameFile, GetFileAttributes, ObtainFile).

The scl package parses SCD, ICD, CID and IID files for schema editions 1.7, 2007B, 2007B4 and 2007C5, detected automatically.

main.go
package main
import (
"fmt"
"log"
"github.com/otfabric/go-iec61850/scl"
"github.com/otfabric/go-iec61850/scl/index"
"github.com/otfabric/go-iec61850/scl/validate"
)
func main() {
doc, err := scl.ParseFile("station.scd")
if err != nil {
log.Fatal(err)
}
for _, ied := range doc.IEDs {
fmt.Printf("IED: %s (%s)\n", ied.Name, ied.Manufacturer)
}
idx, idxDiags := index.Build(doc)
for _, d := range validate.All(doc, idx, idxDiags) {
fmt.Printf("[%s] %s: %s: %s\n", d.Severity, d.Code, d.Path, d.Message)
}
}

Summarize, Flatten / WriteCSV, ExportDataSets, ExportReports and the Find* helpers cover inspection. The sclparse tool also lists GOOSE and SMV control blocks (list-goose, list-smv). Generate writes XML back out, but does not reproduce the original formatting and does not serialise GSE or SMV control blocks. There is no XSD schema validation, only semantic checks.

The server builds an MMS model from SCL and adds a report engine, control state machine, setting groups, journals, and GOOSE and Sampled Values publishing. Its API is covered by the same v1 guarantee as the client.

main.go
package main
import (
"context"
"log"
mms "github.com/otfabric/go-mms"
"github.com/otfabric/go-mms/transport/iso"
"github.com/otfabric/go-iec61850"
"github.com/otfabric/go-iec61850/scl"
)
func main() {
ctx := context.Background()
doc, err := scl.ParseFile("station.icd")
if err != nil {
log.Fatal(err)
}
model, err := iec61850.NewServerModelFromSCL(doc, "IED1", "")
if err != nil {
log.Fatal(err)
}
srv, err := iec61850.NewServer(model, iec61850.ServerOptions{})
if err != nil {
log.Fatal(err)
}
re := srv.EnableReports()
defer re.Stop()
// The MMS domain is the IED name followed by the LD instance (IED1 + InteropLD).
err = srv.RegisterControl("IED1InteropLD", "GGIO1.SPCSO1", iec61850.CtlModelDirectNormal,
iec61850.ControlHandler{
OnOperate: func(ctx context.Context, req iec61850.ControlRequest) error {
log.Printf("operate: %s ctlVal=%v", req.Ref, req.CtlVal)
return nil
},
})
if err != nil {
log.Fatal(err)
}
// Store keys are "LD/itemID"; SetValue triggers change-detection reports.
srv.SetValue(ctx, "IED1InteropLD/GGIO1$ST$SPS1$stVal", mms.NewBoolean(true))
ln, err := iso.Listen(":102")
if err != nil {
log.Fatal(err)
}
log.Fatal(srv.ListenAndServe(ctx, ln))
}

Since v1.7.0 a server built from SCL names its logical devices as IEC 61850-8-1 does, like the other IEC 61850 stacks: the MMS domain is LDevice@ldName when the SCL gives one, otherwise the IED name followed by LDevice@inst (IED1InteropLD here; it was the bare InteropLD). Data set members, report control block DatSet, GoCB and MSVCB references and the keys of SetValue and RegisterControl follow. A client that finds the logical devices with ListLogicalDevices is not affected; one that addresses InteropLD/... directly sets DialOptions.IEDName. NewServerModelFromSCLWithOptions(..., iec61850.ServerModelOptions{InstanceDomainNames: true}) keeps the old names. v1.7.0 also fixed reports with the data-reference bit of OptFlds set, which left the references out; cB-Sigma’s client found it in iec61850-interop.

Control handlers get OnSelect, OnOperate and OnCancel. Selection is owned by the connection that made it and times out after DefaultSelectTimeout (30 s), and a time-activated operate waits for its operTm. After an enhanced-security operate the server sends the CommandTermination. When a request asks for the check conditions, the server runs them: an interlocking check (ControlHandler.CheckInterlock, or a CILO bound with Interlocking, whose EnaCls and EnaOpn must allow the move) at select and operate, and a synchrocheck (CheckSynchro, or an RSYN bound with Synchrocheck, waiting up to SynchroTimeout for Rel) at operate; refusals carry AddCause blocked-by-interlocking or blocked-by-synchrocheck. The algorithm behind the CILO and RSYN values stays your application’s. An opt-in ProcessResponse models a DPC’s travel through the intermediate state, an operation counter and position-reached. Since v1.5.0 the server refuses client writes to the read-only functional constraints ST, MX, SG, SR, OR and EX with object-access-denied, so no MMS client can overwrite a breaker’s Pos.stVal; the application changes them with SetValue. A simulator whose peers drive status over MMS sets ServerOptions.AllowReadOnlyFCWrites. File services need a ServerOptions.FileProvider; there is no built-in filesystem provider. EnableSettingGroups and EnableJournals start the other engines; the setting group engine keeps a value bank per group, filled from SCL Val sGroup, so SelectActiveSG, SelectEditSG, SetEditSGValue and ConfirmEditSGValues work without handler code. The banks are in memory: persist them in OnConfirmEdit and restore them with SetSettingGroupValue. ServerOptions.Authenticate checks the association, and Server.Shutdown(ctx) stops accepting associations and drains the active ones.

One SetValue call updates the model and drives everything that depends on it: reports, journals, GOOSE states and the next Sampled Values. Reports follow BufTm: changes within the buffer time join one report. A BRCB buffer is bounded by entries (1000 by default) and optionally by size, sets BufOvfl when it discards, and can be replaced through ServerOptions.NewReportBuffer, for example by a persistent one. Register a report handler before enabling an RCB: a BRCB sends its buffered entries right after the RptEna response. Known gaps: no dynamic datasets, in-memory setting groups, BRCB buffers and journals by default, and the model is immutable after construction.

ServerOptions.Clock, ClientOptions.Clock, DialOptions.Clock and the Clock of the GOOSE and SV publishers stamp every protocol time: the t of a control, report TimeStamp and TimeOfEntry, journal entries, LActTm, GOOSE T and SV refrTm. ClockWithQuality takes the synchronisation status from wherever the host has it (chrony, ptp4l, the kernel NTP state). Without a Clock, times carry the quality “clock not synchronised” (0x2a), so set one that reports synchronised when the host is. Timers such as sboTimeout, operTm, IntgPd and BufTm stay on the monotonic clock, so a wall-clock step does not fire or stretch them.

The goose package publishes and subscribes on raw Ethernet. Both ends are usually built from the SCL control block: ControlBlockFromSCL returns the multicast address, APPID, VLAN, MinTime and MaxTime, and the dataset layout.

tr, err := goose.Open("eth0", goose.TransportOptions{})
if err != nil {
log.Fatal(err) // wraps goose.ErrPermission without CAP_NET_RAW or /dev/bpf access
}
defer tr.Close()
cb, err := goose.ControlBlockFromSCL(doc, "DemoIED", "LD1", "gcb01")
if err != nil {
log.Fatal(err)
}
cfg, err := cb.PublisherConfig() // address, references, times, initial values
if err != nil {
log.Fatal(err)
}
cfg.Src = tr.HardwareAddr()
pub, err := goose.NewPublisher(tr, cfg)
if err != nil {
log.Fatal(err)
}
defer pub.Close()
go pub.Run(ctx) // sends, then retransmits from MinTime to MaxTime
values := cfg.Values
values[0] = mms.NewBoolean(true) // GGIO1.Ind1.stVal
if err := pub.Publish(values); err != nil { // a new state: stNum+1, sqNum 0
log.Fatal(err)
}

The publisher keeps stNum and sqNum, sends timeAllowedToLive (twice MaxTime unless you set it), and sets the test, simulation and ndsCom flags you ask for.

A subscriber filters by destination, APPID, gocbRef and source, validates datSet, goID, confRev and the member types, and supervises each stream:

sub, err := goose.NewSubscriber(tr, goose.SubscriberConfig{})
if err != nil {
log.Fatal(err)
}
defer sub.Close()
scfg := cb.SubscriptionConfig() // filters and validation from SCL
scfg.OnlyStateChanges = true
s, err := sub.Subscribe(scfg)
if err != nil {
log.Fatal(err)
}
go sub.Run(ctx)
for ev := range s.Events() {
switch ev.Kind {
case goose.EventMessage:
fmt.Println("stNum", ev.Frame.PDU.StNum, ev.Frame.PDU.AllData)
case goose.EventTimeout:
fmt.Println("timeAllowedToLive expired")
case goose.EventInvalid:
fmt.Println("invalid:", ev.Err, errors.Is(ev.Err, goose.ErrConfRevMismatch))
default: // restarts, sequence gaps, duplicates, out of order
}
}

Supervision snapshots in the style of the LGOS logical node are available per stream. The subscriber does not substitute values on a timeout: what a lost input means is your application’s decision.

The sv package does the same for IEC 61850-9-2. A publisher paces samples on an absolute schedule at smpRate, batches noASDU samples per frame and wraps smpCnt; the Source callback fills each sample.

cb, err := sv.ControlBlockFromSCL(doc, "DemoIED", "LD1", "MSVCB01") // 9-2LE, 4000 samples/s
if err != nil {
log.Fatal(err)
}
cfg, err := cb.PublisherConfig()
if err != nil {
log.Fatal(err)
}
cfg.Src = tr.HardwareAddr()
cfg.Source = func(info sv.SampleInfo, dst []byte) []byte { // called for every sample
wt := 2 * math.Pi * 50 * float64(info.Index) / 4000
var s sv.LESample
s.Current[0].Value = sv.AmpsCount(141.4 * math.Sin(wt))
s.Voltage[0].Value = sv.VoltsCount(89800 * math.Sin(wt))
return s.Append(dst)
}
pub, err := sv.NewPublisher(tr, cfg)
if err != nil {
log.Fatal(err)
}
defer pub.Close()
log.Fatal(pub.Run(ctx))

A subscriber validates datSet, confRev, smpRate, smpMod and the sample size, and accounts for every sample from smpCnt: lost, duplicated, out of order. Its receive path does not allocate, so a callback runs per ASDU at full rate:

s, err := sv.NewSubscriber(tr, sv.SubscriberConfig{})
if err != nil {
log.Fatal(err)
}
defer s.Close()
scfg := cb.SubscriptionConfig()
scfg.OnASDU = func(smp *sv.Sample) { // on the receive goroutine
var le sv.LESample
if smp.ASDU.SmpCnt == 0 && sv.DecodeLE(smp.ASDU.Sample, &le) == nil {
fmt.Printf("IA %.1f A, UA %.0f V\n", sv.Amps(le.Current[0].Value), sv.Volts(le.Voltage[0].Value))
}
}
sub, err := s.Subscribe(scfg)
if err != nil {
log.Fatal(err)
}
go func() {
for ev := range sub.Events() { // start, gaps, timeouts, synch changes, invalid ASDUs
fmt.Println(ev.Kind, ev.Stream)
}
}()
err = s.Run(ctx)
for _, st := range sub.Stats() {
fmt.Printf("%s: %d ASDUs, %d lost, %.0f samples/s\n", st.Stream, st.ASDUs, st.Lost, st.Rate)
}

The publisher is software-timed. It reports late and skipped samples, but it is not a merging unit with PTP or 1PPS synchronization: set SmpSynch to what the host clock really provides.

NewServerModelFromSCL reads the GSEControl and SampledValueControl blocks with their addresses. Two calls start publishing them:

tr, _ := goose.Open("eth0", goose.TransportOptions{})
gooseEngine, err := srv.EnableGOOSE(iec61850.GOOSEOptions{Transport: tr})
svTr, _ := sv.Open("eth0", sv.TransportOptions{})
svEngine, err := srv.EnableSV(iec61850.SVOptions{Transport: svTr, SmpSynch: sv.SmpSynchLocal})
srv.SetValue(ctx, "LD0/GGIO1$ST$Ind1$stVal", mms.NewBoolean(true)) // a new GOOSE state

A change of any dataset member, through SetValue or an MMS write, publishes a new GOOSE state; Sampled Values carry the current dataset values at SmpRate, and svEngine.Publisher(ref) takes waveform samples directly. The control blocks are MMS variables too: LLN0$GO$<name> with GoEna, GoID and DatSet writable, LLN0$MS$<name> with SvEna, MsvID, DatSet, SmpRate, OptFlds and SmpMod writable, each only while the block is disabled.

A client reads and writes them on any server:

cb, err := client.GetGoCB(ctx, "LD0", "LLN0$GO$gcb1")
off := false
err = client.SetGoCB(ctx, "LD0", "LLN0$GO$gcb1", iec61850.GoCBUpdate{GoEna: &off})
msvcb, err := client.GetMSVCB(ctx, "MU01", "LLN0$MS$MSVCB01")
on, rate := true, uint16(256)
err = client.SetMSVCB(ctx, "MU01", "LLN0$MS$MSVCB01", iec61850.MSVCBUpdate{SmpRate: &rate, SvEna: &on})

Both setters write the enable attribute last.

The rsession package carries GOOSE and SV over UDP/IP, unicast or multicast, on port 102 by default, with the session protocol of IEC TR 61850-90-5. rsession.Transport implements the transport of goose and sv, so their publishers and subscribers run over it unchanged. Every SPDU is signed with HMAC-SHA256 truncated to 80, 128 or 256 bits, with keys from a KeyProvider (KeyRing is a static one that supports key changes). It is secured by default: Open needs a key provider unless Insecure is set, and a receiver refuses unsecured, unknown-key, tampered and replayed SPDUs, counting them in Stats. Protocol versions 1 and 2 are received; 2 is sent.

Not implemented: AES-GMAC and AES-GCM encryption, tunnelled and management SPDUs, IEC 62351-9 key distribution, and the SCL IP addresses of R-GOOSE and R-SV control blocks. A restarted publisher’s SPDUs are refused as replays until the key changes, unless ReplayResetAfter or InitialSPDUNumber is used.

Platform Transport Privilege
Linux AF_PACKET CAP_NET_RAW (sudo setcap cap_net_raw+ep ./myapp) or root
macOS, BSD BPF Read and write access to /dev/bpf*, for example the access_bpf group
Windows and others none Open returns ErrUnsupportedPlatform
Everywhere In-memory Hub with fault injection none, for tests and simulation

goose and sv share the l2 types, so one socket can carry both EtherTypes. Set TransportOptions.Multicast to the control blocks’ destination addresses so the network card filters in hardware; without it the transport receives all multicast. Keep the VLAN ID and priority from SCL, and check that every switch on the path forwards 802.1Q-tagged frames. A subscriber to many 4 kHz streams needs a larger socket receive buffer (net.core.rmem_default on Linux).

go-mms gives you MMS without IEC 61850 naming: Identify, Status, Read / Write by domain and item ID (with alternate access by component, index or range), named variable lists, GetNameListAll, GetVariableAccessAttributes, OnInformationReport, file and journal services.

client, err := iso.Dial(ctx, "10.0.0.1:102",
iso.WithClientDialOptions(mms.DialOptions{MMS: mms.MMSOptions{MaxPDUSize: 65000}}),
)
if err != nil {
log.Fatal(err)
}
defer client.Close(ctx)
id, _ := client.Identify(ctx)
fmt.Println(id.Vendor, id.Model, id.Revision)
res, err := client.Read(ctx, mms.ReadRequest{DomainID: "MyDomain", ItemID: "MyVariable"})

DialOptions.AllowedServices limits a client to an allow-list of confirmed services: anything else is refused before it is sent, with ErrServiceNotAllowed, and the association stays usable. DecodeTSDU and DecodePDU decode captured traffic passively, through the session, presentation and ACSE layers to the MMS PDU, naming every ISO 9506 service; go-mms-trace builds on them. iso.WithDialer takes a dialer with the contract of net.Dialer, and the server advertises only the services it can serve (file services only with a FileProvider, journals only with a journal provider).

go-mms does not implement semaphore, event management, program invocation or client-side MMS Cancel services, and supports COTP class 0 over TCP only. Since v1.1.0 every exported method is exercised between its own client and server in an end-to-end suite. That release fixed sixteen wire and behaviour bugs found this way and by the wider interop suite, among them FileDirectory against conforming servers and FileDelete; v1.2.0 fixed codec bugs found by its 57 fuzz targets, such as the Cancel PDU tags and BinaryTime. v1.3.0 added the extended length form of session SPDUs (an AARQ with a long ACSE password was unparseable before) and refuses out-of-range values instead of wrapping them: a UtcTime outside 1970 to 2106, negative or oversized invoke IDs, file sizes beyond Unsigned32. It has 70 fuzz targets.

go-iec61850 errors wrap sentinels for errors.Is and typed structs for errors.As. Lower-level go-mms errors stay in the chain.

val, err := client.Read(ctx, ref)
switch {
case err == nil:
fmt.Println(val)
case errors.Is(err, iec61850.ErrNotFound):
// object does not exist on this server
case errors.Is(err, iec61850.ErrDataAccess):
// per-variable access failure, for example access denied
case errors.Is(err, iec61850.ErrClosed), errors.Is(err, mms.ErrClosed):
// connection gone: reconnect
case errors.Is(err, context.DeadlineExceeded):
// timed out: retry or widen the deadline
default:
var se *mms.ServiceError
if errors.As(err, &se) {
log.Printf("MMS error class=%d code=%d", se.Class, se.Code)
}
}

Control failures wrap ErrControlFailed plus ErrSelectFailed, ErrOperateFailed or ErrCancelFailed, and ErrNotControllable for status-only objects; extract details with *iec61850.ControlError. Other sentinels include ErrInvalidReference, ErrTypeMismatch, ErrUnsupportedService, ErrSubscriptionClosed, ErrSCLParse and ErrGOOSE.

go-mms classifies every failure the same way: ErrAssociationFailed, ErrNegotiationFailed, ErrClosed, ErrInvokeTimeout (with context.DeadlineExceeded), ErrInvalidArgument and ErrServerClosed, plus *mms.RejectError for MMS Reject PDUs. ServiceError.CodeName() gives the ISO 9506-2 name of an error code, and Error() now ends with it, so compare with errors.Is and errors.As, never with the message text. The goose and sv packages have their own sentinels, such as ErrPermission, ErrUnsupportedPlatform, ErrInvalidFrame and ErrConfRevMismatch.

  • Every network call takes a context.Context. Reads and writes have separate deadlines (go-cotp v1.1.0), so a short write deadline no longer cuts a concurrent read.
  • A request whose context ends before any byte moved returns the context error and leaves the association usable. Once bytes have moved, the connection is aborted rather than left half-written.
  • DialOptions.Retry retries the connection with backoff and jitter. There is no automatic reconnect of a live association: on ErrClosed, dial again and re-subscribe. The go-iec61850 server releases a URCB reservation when its connection drops.
  • On the server, AssociationTimeout (30 s by default) aborts an association that never completes its handshake, and the listener runs TLS and COTP handshakes concurrently, so a silent peer cannot block others.
  • *iec61850.Client is safe for concurrent use. go-mms correlates responses by invoke ID and serialises writes. Since go-mms v1.9.0 the client keeps to what Initiate negotiated: a request made at the limit of outstanding requests waits for a free slot (MMSOptions.FailFastOutstanding returns ErrMaxOutstanding instead), and data deeper than the negotiated nesting level is refused.
  • A go-mms server handles confirmed requests on one connection serially.
  • InformationReport handlers in go-mms run on the reader goroutine and must return quickly.

Pass a *slog.Logger in DialOptions or ServerOptions. With no logger nothing is emitted. Debug covers protocol flow and every request (service, invoke ID, duration, error), Info covers lifecycle and control operations, Warn covers retries, report overflow and recoverable issues. The ISO layer logger (iso.WithLogger) is separate. For wire debugging, mms.DialOptions.RawHook sees every raw upper-layer packet on the client.

For metrics, implement mms.Metrics (ObserveRequest, ObserveConnection) and pass it in DialOptions.Metrics or ServerOptions.Metrics; the go-mms repository has a Prometheus example. The goose and sv packages have their own Metrics hooks for frames, states, losses and timeouts. There is no built-in tracing.

  • No IEC 62351-6 security for layer-2 GOOSE and SV (protect the process bus at the network layer, or use R-GOOSE and R-SV), no encryption on R-GOOSE and R-SV, no unicast SV, no GOOSE management. The fixed-offset GOOSE encoding is not verified against an independent implementation.
  • Received GOOSE values are not mapped into a server model (ExtRef binding); map them from the subscriber events.
  • Primary baseline is IEC 61850 Edition 2 (2007B). Edition 2.1 features are partially validated.
  • Not every ACSI service is mapped. BRCB ResvTms and Owner are not modelled, and the operative tests other than interlocking and synchrocheck (behaviour, blocking, local/remote) are left to OnSelect and OnOperate.
  • Tested in both directions against five independent software stacks; not certified, and interoperability with physical IEDs has not been formally established. See Testing and interop.