이 번역 페이지는 최신 내용을 담고 있지 않습니다. 최신 내용을 영문으로 보려면 여기를 클릭하십시오.
pcapReader
설명
pcapReader
객체는 이더넷과 eCPRI(Enhanced Common Public Radio Interface) 프로토콜 패킷을 특정 기준에 따라 읽어오고 디코딩합니다. 사용자 지정 프로토콜 디코더를 연결할 수도 있습니다.
생성
설명
는 OutputTimestampFormat 속성을 pcap
= pcapReader(filename
,OutputTimestampFormat='seconds'
)seconds
로 설정합니다.
입력 인수
filename
— PCAP 파일 이름
문자형 벡터 | string형 스칼라
확장자를 포함한 PCAP 파일 이름으로, 문자형 벡터 또는 string형 스칼라로 지정됩니다.
예: "ethernetSamplePackets.pcap"
데이터형: char
| string
속성
OutputTimestampFormat
— 패킷 타임스탬프의 출력 형식
'microseconds'
(디폴트 값) | 'seconds'
| 'datetime'
패킷 타임스탬프의 출력 형식으로, 'microseconds'
, 'seconds'
또는 'datetime'
으로 지정됩니다. 이 값은 디코딩된 프로토콜 패킷의 타임스탬프를 지정합니다.
데이터형: char
| string
MajorVersion
— PCAP 파일 형식의 주 버전
음이 아닌 스칼라
읽기 전용 속성입니다.
PCAP 파일 형식의 주 버전으로, 음이 아닌 스칼라로 반환됩니다.
데이터형: double
MinorVersion
— PCAP 파일 형식의 부 버전
음이 아닌 스칼라
읽기 전용 속성입니다.
PCAP 파일 형식의 부 버전으로, 음이 아닌 스칼라로 반환됩니다.
데이터형: double
SnapLength
— PCAP 파일 패킷의 최대 길이
음이 아닌 스칼라
읽기 전용 속성입니다.
PCAP 파일 패킷의 최대 길이로, 음이 아닌 스칼라로 반환됩니다.
데이터형: double
LinkType
— PCAP 전역 헤더의 링크 유형
음이 아닌 스칼라
읽기 전용 속성입니다.
PCAP 전역 헤더의 링크 유형으로, 음이 아닌 스칼라로 반환됩니다. 이 속성에 대한 자세한 내용을 보려면 Tcpdump/Libpcap 공개 리포지토리[1] 항목을 참조하십시오.
데이터형: double
LinkName
— PCAP file reader 객체가 제공한 링크 유형 이름
문자형 벡터
읽기 전용 속성입니다.
PCAP file reader 객체가 제공한 링크 유형 이름으로, 문자형 벡터로 반환됩니다.
데이터형: char
NanoSecResolution
— PCAP 파일에 패킷 타임스탬프에 대한 나노초 분해능이 있는지 여부를 나타내는 플래그
1
또는 true
| 0
또는 false
읽기 전용 속성입니다.
PCAP 파일에 패킷 타임스탬프에 대한 나노초 분해능이 있는지 여부를 나타내는 플래그로, 1
(true
) 또는 0
(false
)으로 반환됩니다.
데이터형: logical
객체 함수
이 객체에 한정
addLinkTypeDecoder | Add custom link layer protocol decoder to PCAP file reader |
addUpperLayerDecoder | Add custom upper-layer protocol decoder to PCAP file reader |
read | Read next protocol packet from PCAP file |
readAll | Read all protocol packets from current position to end of PCAP file |
reset | Reset position of PCAP file reader to first protocol packet of PCAP file |
예제
PCAP 파일에서 이더넷 패킷 읽어오기
PCAP 파일의 이름을 지정하여 PCAP file reader 객체를 생성합니다.
pcapReaderObj = pcapReader('ethernetSamplePackets.pcap');
PCAP 파일에서 MATLAB® 작업 공간으로 패킷을 모두 읽어옵니다.
decodedPackets = readAll(pcapReaderObj)
decodedPackets=1×35 struct array with fields:
SNo
Timestamp
LinkType
Protocol
PacketLength
Packet
RawBytes
스트리밍 모드에서 PCAP 파일의 이더넷 패킷 읽기
PCAP 파일의 이름과 패킷 타임스탬프의 출력 형식을 지정하여 PCAP file reader 객체를 생성합니다.
pcapReaderObj = pcapReader('ethernetSamplePackets.pcap', ... OutputTimestampFormat='datetime');
이더넷 소스 주소와 이더넷 유형에 대한 필터를 생성합니다.
filterString = ['eth.SourceAddress == 44FB5A9710AC && ' ... 'eth.Type == 2048'];
스트리밍 모드에서 MATLAB 작업 공간을 대상으로, 지정된 필터와 일치하는 이더넷 패킷을 읽어옵니다.
for packetCount = 1:3 ethPacket = read(pcapReaderObj,filterString) end
ethPacket = struct with fields:
SNo: 1
Timestamp: 08-Feb-2021 03:27:18.043900
LinkType: 1
Protocol: 'eth'
PacketLength: 171
Packet: [1x1 struct]
RawBytes: [1x0 double]
TimestampSec: 1.6128e+09
ethPacket = struct with fields:
SNo: 4
Timestamp: 08-Feb-2021 03:27:19.098190
LinkType: 1
Protocol: 'eth'
PacketLength: 120
Packet: [1x1 struct]
RawBytes: [1x0 double]
TimestampSec: 1.6128e+09
ethPacket = struct with fields:
SNo: 5
Timestamp: 08-Feb-2021 03:27:20.145857
LinkType: 1
Protocol: 'eth'
PacketLength: 171
Packet: [1x1 struct]
RawBytes: [1x0 double]
TimestampSec: 1.6128e+09
PCAP 파일에서 eCPRI 패킷 읽어오기
PCAP 파일의 이름을 지정하여 PCAP file reader 객체를 생성합니다.
pcapReaderObj = pcapReader('ethernetSamplePackets.pcap');
eCPRI 메시지 유형을 지정하여 eCPRI 패킷에 대한 필터를 생성합니다.
filterString = ['ecpri.MessageType == IQData || ecpri.MessageType == BitSequence ' ... '|| ecpri.MessageType == RemoteReset'];
MATLAB 작업 공간을 대상으로, 지정된 필터와 일치하는 eCPRI 패킷을 읽어옵니다.
ecpriFilteredFirstPacket = read(pcapReaderObj,filterString)
ecpriFilteredFirstPacket = struct with fields:
SNo: 21
Timestamp: 1.6128e+15
LinkType: 1
Protocol: 'eth'
PacketLength: 64
Packet: [1x1 struct]
RawBytes: [1x0 double]
ecpriFilteredSecondPacket = read(pcapReaderObj,filterString)
ecpriFilteredSecondPacket = struct with fields:
SNo: 22
Timestamp: 1.6128e+15
LinkType: 1
Protocol: 'eth'
PacketLength: 64
Packet: [1x1 struct]
RawBytes: [1x0 double]
ecpriFilteredRemainingPackets = readAll(pcapReaderObj,filterString)
ecpriFilteredRemainingPackets=1×5 struct array with fields:
SNo
Timestamp
LinkType
Protocol
PacketLength
Packet
RawBytes
PCAP 파일 리더의 위치를 PCAP 파일의 첫 번째 패킷으로 재설정합니다.
reset(pcapReaderObj);
메시지 유형을 IQ(in-phase and quadrature) 데이터로 지정하여 동일한 PCAP 파일에 대한 새 필터를 생성합니다.
filterString = 'ecpri.MessageType == IQData';
MATLAB 작업 공간을 대상으로, 지정된 필터와 일치하는 eCPRI 패킷을 읽어옵니다.
ecpriFilteredPackets = readAll(pcapReaderObj,filterString)
ecpriFilteredPackets = struct with fields:
SNo: 21
Timestamp: 1.6128e+15
LinkType: 1
Protocol: 'eth'
PacketLength: 64
Packet: [1x1 struct]
RawBytes: [1x0 double]
참고 문헌
[1] Group, The Tcpdump. “Tcpdump/Libpcap Public Repository.” Accessed May 20, 2020. https://www.tcpdump.org.
[2] “Development/LibpcapFileFormat - The Wireshark Wiki.” Accessed May 20, 2020. https://www.wireshark.org.
[3] “Common Public Radio Interface: eCPRI Interface Specification V1.2 ” Accessed June 22, 2021.
버전 내역
R2021b에 개발됨
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)