1

I am using pyshark to read packets from a capture file. I can access the sv.smpCnt layer of the package and all values for analysis. I am not able to extract only the numeric value, without the text <LayerField sv.smpCnt:>.

import pyshark
import numpy as np    

capture = pyshark.FileCapture('teste3.pcapng',display_filter='eth.type==0x88ba')  # Ethernet type 0x88ba (Simple Values Transmission)

pkt = capture[1]
B=(pkt.sv.smpCnt.all_fields)

The element B obtained is:

[<LayerField sv.smpCnt: 10848>, <LayerField sv.smpCnt: 10849>, <LayerField sv.smpCnt: 10850>, <LayerField sv.smpCnt: 10851>, <LayerField sv.smpCnt: 10852>, <LayerField sv.smpCnt: 10853>, <LayerField sv.smpCnt: 10854>, <LayerField sv.smpCnt: 10855>]

The package is very long, so I only present a part of it:

Packet (Length: 777)
Layer ETH:
    Destination: 01:0c:cd:04:00:00
    Address: 01:0c:cd:04:00:00
    .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
    .... ...1 .... .... .... .... = IG bit: Group address (multicast/broadcast)
    Source: 00:50:c2:4f:91:99
    Type: IEC 61850/SV (Sampled Value Transmission (0x88ba)
    Address: 00:50:c2:4f:91:99
    .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
    .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
Layer SV:
    APPID: 0x4000
    Length: 763
    Reserved 1: 0x0000 (0)
    Reserved 2: 0x0000 (0)
    savPdu
    noASDU: 8
    seqASDU: 8 items
    ASDU
    svID: 0000MU0102
    smpCnt: 10848
    confRef: 1
    smpSynch: local (1)
    PhsMeas1
    value: 150470
    quality: 0x00000000, validity: good, source: process
    .... .... .... .... .... .... .... ..00 = validity: good (0x0)
    .... .... .... .... .... .... .... .0.. = overflow: False
    .... .... .... .... .... .... .... 0... = out of range: False
    .... .... .... .... .... .... ...0 .... = bad reference: False
    .... .... .... .... .... .... ..0. .... = oscillatory: False
    .... .... .... .... .... .... .0.. .... = failure: False
    .... .... .... .... .... .... 0... .... = old data: False
    .... .... .... .... .... ...0 .... .... = inconsistent: False
    .... .... .... .... .... ..0. .... .... = inaccurate: False
    .... .... .... .... .... .0.. .... .... = source: process (0x0)
    .... .... .... .... .... 0... .... .... = test: False
    .... .... .... .... ...0 .... .... .... = operator blocked: False
    .... .... .... .... ..0. .... .... .... = derived: False
    ASDU
    ASDU
    ASDU
    ASDU
    ASDU
    ASDU
    ASDU
    svID: 0000MU0102
    svID: 0000MU0102
    svID: 0000MU0102
    svID: 0000MU0102
    svID: 0000MU0102
    svID: 0000MU0102
    svID: 0000MU0102
    smpCnt: 10849
    smpCnt: 10850
    smpCnt: 10851
    smpCnt: 10852
    smpCnt: 10853
    smpCnt: 10854
    smpCnt: 10855
    confRef: 1

I would like to get a vector from B containing only the numerical values after the two points. Can someone help me?

1 Answers1

0

Try:

pkt.sv.get_field_by_showname("name of field")
Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
  • Cody Gray, thanks for the answer. I did what you suggested `pkt.sv.get_field_by_showname("smpCnt")` , but I can only get the first field value, `10848`. I would like to get all the values of only mode. – Guilherme Alves Feb 12 '19 at 17:24
  • Ram Ghadiyaram, I should read data via ethernet live or through a wireshark capture. These data are obtained through the Phase Metering Units (PMUs) of substations in the format C37.111-1999 - IEEE Standard Common Format for Transient Data Exchange (COMTRADE) for Power Systems. After reading, I have to read the data and store them for treatment and analysis. So, I want to store only the numeric values of the field `smpCnt`, which is of my interest. In order for the processing time to be fast, I would like to get the data from the layers as fast and in one go. – Guilherme Alves Feb 12 '19 at 17:43