You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Go结构体解析TCP抓包中的ASN.1十六进制编码数据

Let's break down your hex-encoded ASN.1 BER data step by step using the provided ConnectionEstablishedReply and MessageFields definitions:

First, note that the initial 18 00 1c bytes appear to be a TCP payload prefix (possibly a protocol-specific length header), since the ASN.1 sequence starts at 30.

Parsing the ASN.1 BER Data

Top-Level: ConnectionEstablishedReply (SEQUENCE)

  • Tag: 30 (Universal constructed sequence)
  • Length: 80 (Indefinite length, meaning the sequence ends with 00 00)

1. message (MessageFields SEQUENCE)

This is the first element, tagged as a0 (context-specific constructed tag 0):

  • Tag: a0
  • Length: 80 (indefinite length, ends with 00 00)
  • Inner values:
    • messageSequence: 80 01 06 → Context-specific primitive tag 0, length 1, value 06 = 6 (fits the 1..65535 constraint)
    • bsId (optional): 83 02 00 e2 → Context-specific primitive tag3, length2, value 00 e2 = 226 (valid integer in range)
    • Terminator: 00 00 (closes the MessageFields sequence)

2. nackReason (Optional)

Present here as a2 (context-specific constructed tag2):

  • Tag: a2
  • Length: 80 (indefinite length, ends with 00 00)
  • Inner value: 80 01 01 → Context-specific primitive tag0, length1, value 01 = 1 (assuming NackReason is an integer/enum type)
  • Terminator: 00 00 (closes this sequence)

3. interfaceVersion

  • Tag: 81 (context-specific primitive tag1)
  • Length: 01
  • Value: 0d = 13

4. mediatorId

  • Tag: 83 (context-specific primitive tag3)
  • Length: 01
  • Value: 65 = 101 (fits 1..65535)

5. waitForCommit (Optional)

Not present in this encoding (no corresponding TLV found before the top-level terminator)

Final Decoded Structure

ConnectionEstablishedReply {
  message: {
    messageSequence: 6,
    bsId: 226
  },
  nackReason: 1,
  interfaceVersion: 13,
  mediatorId: 101
}

内容的提问来源于stack exchange,提问作者gvij

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:59:29