Commit 934ebcbf authored by Yann Garcia's avatar Yann Garcia
Browse files

Enhance Wireshark dissectors

parent f662f733
Loading
Loading
Loading
Loading
+1 −1
Changes for charts/dev-tooling/meep-virt-chart-templates/values-template.yaml: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ service:
  type: {{.Service.Type}}
  ports:
    {{- range .Service.Ports}}
    - name: port-{{.Port}}
    - name: {{if eq .Protocol "UDP"}}udp-{{.Port}}{{else if eq .Protocol "SCTP"}}sctp-{{.Port}}{{else}}tcp-{{.Port}}{{end}}
      port: {{.Port}}
      targetPort: {{.TargetPort}}
      protocol: {{.Protocol}}
+9 −6
Changes for tools/simu5g/simu5g_activate.py: 9 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -539,10 +539,12 @@ class _Handler(object):
        if path in ("/v1/start", "/start") and environ_method == "POST":
            inst = json.loads(body or "{}")
            sandbox = inst.get("sandbox_id") or self.args.namespace
            self.args.namespace = sandbox
            self.args.force = True
            cfg_path, slot, _ = prepare_config(self.args, inst)
            if is_root() or self.args.host_root:
            # Copy: mutating self.args.namespace breaks serve --watch -n '*'.
            one = copy.copy(self.args)
            one.namespace = sandbox
            one.force = True
            cfg_path, slot, _ = prepare_config(one, inst)
            if is_root() or one.host_root:
                activate_as_root(cfg_path, sandbox, slot, sandbox)
            else:
                run_via_kubectl_job(sandbox, "activate", config_file=str(cfg_path))
@@ -550,8 +552,9 @@ class _Handler(object):
        if path in ("/v1/stop", "/stop") and environ_method == "POST":
            payload = json.loads(body or "{}")
            sandbox = payload.get("sandbox_id") or self.args.namespace
            self.args.namespace = sandbox
            deactivate(self.args)
            one = copy.copy(self.args)
            one.namespace = sandbox
            deactivate(one)
            return 200, {"ok": True, "sandbox": sandbox}
        return 404, {"error": "not found"}

+11 −1
Changes for tools/simu5g/wireshark/rni_udp.lua: 11 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -83,6 +83,8 @@ local pf_reqpad = ProtoField.bytes("rniudp.req_pad", "Request pad")
local pf_app        = ProtoField.string("rniudp.me_app", "ME app instance")
local pf_status     = ProtoField.uint32("rniudp.status", "Status", base.DEC, status_names)
local pf_plen       = ProtoField.uint32("rniudp.payload_len", "Payload length", base.DEC)
local pf_rawpay     = ProtoField.bytes("rniudp.payload", "UDP/RNI payload bytes")
local pf_rawpay_ascii = ProtoField.string("rniudp.payload_ascii", "UDP/RNI payload (ASCII)")
local pf_num        = ProtoField.uint16("rniudp.num", "Row count", base.DEC)
local pf_paypad     = ProtoField.bytes("rniudp.payload_pad", "Payload pad")
local pf_uename     = ProtoField.string("rniudp.ue_name", "UE name")
@@ -117,7 +119,7 @@ local pf_rowpad = ProtoField.bytes("rniudp.row_pad", "Reserved")

rni.fields = {
    pf_magic, pf_ver, pf_class, pf_query, pf_rid, pf_applen, pf_reqpad, pf_app,
    pf_status, pf_plen, pf_num, pf_paypad, pf_uename, pf_ipv4, pf_ecgi,
    pf_status, pf_plen, pf_rawpay, pf_rawpay_ascii, pf_num, pf_paypad, pf_uename, pf_ipv4, pf_ecgi,
    pf_mcc, pf_mnc, pf_qci, pf_lte_node, pf_nr_node, pf_uecount, pf_is_nr,
    pf_enb_teid, pf_sgw_teid, pf_bearer, pf_rsrp10, pf_rsrq10, pf_rsrp, pf_rsrq,
    pf_dl_prb, pf_ul_prb, pf_dl_bps, pf_ul_bps, pf_dl_lat, pf_ul_lat,
@@ -378,6 +380,14 @@ function rni.dissector(tvb, pinfo, tree)
        end
        local payload = tvb(RSP_HDR_LEN, plen):tvb()
        local ptree = subtree:add(rni, tvb(RSP_HDR_LEN, plen), "Payload")
        subtree:add(pf_rawpay, tvb(RSP_HDR_LEN, plen))
        local ascii = {}
        local n = math.min(plen, 256)
        for i = 0, n - 1 do
            local b = tvb(RSP_HDR_LEN + i, 1):uint()
            ascii[#ascii + 1] = (b >= 32 and b < 127) and string.char(b) or "."
        end
        subtree:add(pf_rawpay_ascii, tvb(RSP_HDR_LEN, plen), table.concat(ascii))
        if payload:len() < 8 then
            ptree:add_proto_expert_info(ef_short)
        else
+30 −0
Changes for tools/simu5g/wireshark/run_tshark_rni.sh: 30 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -5,6 +5,10 @@
# Usage:
#   ./tools/simu5g/wireshark/run_tshark_rni.sh -r rni.pcap -Y rniudp
#   ./tools/simu5g/wireshark/run_tshark_rni.sh rni.pcap
#   ./tools/simu5g/wireshark/run_tshark_rni.sh -r rni.pcap --payload
#
# Default is --no-payload (one-line Info column). --payload prints UDP
# payload (hex + ASCII) and rniudp.payload*.
set -euo pipefail

readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
@@ -28,6 +32,7 @@ stage_path() {
  printf '%s\n' "$dest"
}

show_payload=0
args=(-X "lua_script:${STAGE}/rni_udp.lua")
if [[ $# -eq 1 && -f "$1" && "$1" != -* ]]; then
  args+=(-r "$(stage_path "$1")" -Y rniudp)
@@ -35,6 +40,14 @@ if [[ $# -eq 1 && -f "$1" && "$1" != -* ]]; then
else
  while [[ $# -gt 0 ]]; do
    case "$1" in
      --payload)
        show_payload=1
        shift
        ;;
      --no-payload)
        show_payload=0
        shift
        ;;
      -r|--read-file)
        [[ $# -ge 2 ]] || { echo "missing file after $1" >&2; exit 2; }
        args+=(-r "$(stage_path "$2")")
@@ -48,4 +61,21 @@ else
  done
fi

user_output=0
for a in "${args[@]}"; do
  case "$a" in
    -T|-V|-e|-x|--hexdump) user_output=1 ;;
  esac
done

if [[ "$show_payload" -eq 1 && "$user_output" -eq 0 ]]; then
  args+=(
    -T fields -E header=y -E separator=/t -E quote=d -E occurrence=f
    -e frame.number -e frame.time_relative
    -e ip.src -e ip.dst -e udp.srcport -e udp.dstport -e udp.length
    -e rniudp.msg_class -e rniudp.query -e rniudp.payload_len
    -e rniudp.payload_ascii -e rniudp.payload -e udp.payload
  )
fi

exec tshark "${args[@]}"
+31 −0
Changes for tools/simu5g/wireshark/run_tshark_s5.sh: 31 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -5,6 +5,11 @@
# Usage:
#   ./tools/simu5g/wireshark/run_tshark_s5.sh -r B_to_S.pcap -Y s5uldl
#   ./tools/simu5g/wireshark/run_tshark_s5.sh B_to_S.pcap
#   ./tools/simu5g/wireshark/run_tshark_s5.sh -r S_to_B.pcap --payload
#
# Default is --no-payload (one-line Info column). --payload prints inner
# UDP/TCP payload (hex + ASCII) via s5uldl.payload*. Pass -T/-V/-e yourself
# to keep full control of TShark output.
set -euo pipefail

readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
@@ -28,6 +33,7 @@ stage_path() {
  printf '%s\n' "$dest"
}

show_payload=0
args=(-X "lua_script:${STAGE}/s5_uldl.lua")
if [[ $# -eq 1 && -f "$1" && "$1" != -* ]]; then
  args+=(-r "$(stage_path "$1")" -Y s5uldl)
@@ -35,6 +41,14 @@ if [[ $# -eq 1 && -f "$1" && "$1" != -* ]]; then
else
  while [[ $# -gt 0 ]]; do
    case "$1" in
      --payload)
        show_payload=1
        shift
        ;;
      --no-payload)
        show_payload=0
        shift
        ;;
      -r|--read-file)
        [[ $# -ge 2 ]] || { echo "missing file after $1" >&2; exit 2; }
        args+=(-r "$(stage_path "$2")")
@@ -48,4 +62,21 @@ else
  done
fi

user_output=0
for a in "${args[@]}"; do
  case "$a" in
    -T|-V|-e|-x|--hexdump) user_output=1 ;;
  esac
done

if [[ "$show_payload" -eq 1 && "$user_output" -eq 0 ]]; then
  args+=(
    -T fields -E header=y -E separator=/t -E quote=d -E occurrence=f
    -e frame.number -e frame.time_relative
    -e s5uldl.type -e s5uldl.ueid -e s5uldl.destid
    -e s5uldl.l4 -e s5uldl.sport -e s5uldl.dport
    -e s5uldl.payload_ascii -e s5uldl.payload
  )
fi

exec tshark "${args[@]}"
Loading