PcapFileEx.Flows.UDP.Flow (pcap_file_ex v0.5.5)
View SourceA UDP flow containing datagrams.
Groups UDP datagrams by destination (server) endpoint. Unlike HTTP flows,
UDP flows use from: :any because datagrams are grouped by server only,
regardless of source.
Fields
flow- The baseFlowidentity (protocol, endpoints, display fields)datagrams- List ofUDP.Datagramstructsstats- Aggregate statistics for this flow
UDP Grouping
UDP datagrams are grouped by destination (server) IP:port only. All datagrams to the same server form a single flow:
%Flow{
protocol: :udp,
from: :any, # Datagrams may come from any source
server: "metrics-collector:5005",
client: nil,
client_endpoint: nil
}Examples
# Get all datagrams to a specific server
result.udp
|> Enum.filter(fn f -> f.flow.server == "metrics-collector:5005" end)
|> Enum.flat_map(& &1.datagrams)
# Calculate total bytes to each UDP server
result.udp
|> Enum.map(fn f -> {f.flow.server, f.stats.byte_count} end)
Summary
Functions
Adds a datagram to the flow.
Finalizes the flow by computing relative offsets for all datagrams.
Creates a new UDP flow.
Types
@type t() :: %PcapFileEx.Flows.UDP.Flow{ datagrams: [PcapFileEx.Flows.UDP.Datagram.t()], flow: PcapFileEx.Flow.t(), stats: PcapFileEx.Flows.Stats.t() }
Functions
@spec add_datagram(t(), PcapFileEx.Flows.UDP.Datagram.t()) :: t()
Adds a datagram to the flow.
Parameters
udp_flow- The UDP flowdatagram- The datagram to add
Finalizes the flow by computing relative offsets for all datagrams.
Called after all datagrams have been added.
@spec new(PcapFileEx.Flow.t()) :: t()
Creates a new UDP flow.
Parameters
flow- The base Flow identity (should haveprotocol: :udp)
Examples
alias PcapFileEx.{Flow, Endpoint}
alias PcapFileEx.Flows.UDP
server = Endpoint.new("10.0.0.2", 5005, "metrics-collector")
flow = Flow.new(:udp, nil, server)
udp_flow = UDP.Flow.new(flow)