fiorix / go-diameter

Diameter stack and Base Protocol (RFC 6733) for the Go programming language
Other
244 stars 141 forks source link

Introducing an Alternative for Visualizing Diameter Messages. #185

Closed lwlee2608 closed 10 months ago

lwlee2608 commented 10 months ago

I would like to propose a new format for visualizing Diameter messages.

Current diam.Message.String() output:

    Credit-Control-Request (CCR)
    {Code:272,Flags:0x80,Version:0x1,Length:244,ApplicationId:4,HopByHopId:0xa8cc407d,EndToEndId:0xa8c1b2b4}
            Origin-Host {Code:264,Flags:0x40,Length:12,VendorId:0,Value:DiameterIdentity{test},Padding:0}
            Origin-Realm {Code:296,Flags:0x40,Length:20,VendorId:0,Value:DiameterIdentity{localhost},Padding:3}
            Host-IP-Address {Code:257,Flags:0x40,Length:16,VendorId:0,Value:Address{10.1.0.1},Padding:2}
            Vendor-Id {Code:266,Flags:0x40,Length:12,VendorId:0,Value:Unsigned32{13}}
            Session-Id {Code:263,Flags:0x40,Length:24,VendorId:0,Value:UTF8String{sess;123456789},Padding:2}
            Origin-State-Id {Code:278,Flags:0x40,Length:12,VendorId:0,Value:Unsigned32{1397760650}}
            CC-Request-Type {Code:416,Flags:0x40,Length:12,VendorId:0,Value:Enumerated{1}}
            CC-Request-Number {Code:415,Flags:0x40,Length:12,VendorId:0,Value:Unsigned32{1000}}
            Multiple-Services-Credit-Control {Code:456,Flags:0x40,Length:48,VendorId:0,Value:Grouped{
                    Service-Identifier {Code:439,Flags:0x40,Length:12,VendorId:0,Value:Unsigned32{7786}},
                    Rating-Group {Code:432,Flags:0x40,Length:12,VendorId:0,Value:Unsigned32{7786}},
                    TGPP-RAT-Type {Code:21,Flags:0xc0,Length:16,VendorId:10415,Value:OctetString{0x31323334},Padding:0},
            }}
            Service-Information {Code:873,Flags:0xc0,Length:56,VendorId:10415,Value:Grouped{
                    PS-Information {Code:874,Flags:0xc0,Length:44,VendorId:10415,Value:Grouped{
                            Called-Station-Id {Code:30,Flags:0x40,Length:16,VendorId:0,Value:UTF8String{10999},Padding:3},
                            Start-Time {Code:2041,Flags:0xc0,Length:16,VendorId:10415,Value:Time{2013-08-21 22:06:14 +0800 +08}},
                    }}
            }}

Proposed new diam.Message.PrettyDump()

      Credit-Control(272) Charging-Control(4) request 2831958141, 2831266484
        AVP                                        Vendor  Code  V M P  Type                Value
        Origin-Host                                     0   264  ✗ ✓ ✗  DiameterIdentity    test
        Origin-Realm                                    0   296  ✗ ✓ ✗  DiameterIdentity    localhost
        Host-IP-Address                                 0   257  ✗ ✓ ✗  Address             10.1.0.1
        Vendor-Id                                       0   266  ✗ ✓ ✗  Unsigned32          13
        Session-Id                                      0   263  ✗ ✓ ✗  UTF8String          sess;123456789
        Origin-State-Id                                 0   278  ✗ ✓ ✗  Unsigned32          1397760650
        CC-Request-Type                                 0   416  ✗ ✓ ✗  Enumerated          1
        CC-Request-Number                               0   415  ✗ ✓ ✗  Unsigned32          1000
        Multiple-Services-Credit-Control                0   456  ✗ ✓ ✗  Grouped
          Service-Identifier                            0   439  ✗ ✓ ✗  Unsigned32          7786
          Rating-Group                                  0   432  ✗ ✓ ✗  Unsigned32          7786
          TGPP-RAT-Type                             10415    21  ✗ ✓ ✗  OctetString         1234
        Service-Information                         10415   873  ✓ ✓ ✗  Grouped
          PS-Information                            10415   874  ✓ ✓ ✗  Grouped
            Called-Station-Id                           0    30  ✓ ✓ ✗  UTF8String          10999
            Start-Time                              10415  2041  ✓ ✓ ✗  Time                2013-08-21 22:06:14 +0800 +08

I am open to any comments, feedback, or suggestions and would be happy to discuss further.

fiorix commented 10 months ago

Thank you!