({{, (RefLink[NetworkPacketTrace, paclet:ref/NetworkPacketTrace])[expr]
evaluates expr and returns information on network packets transmitted or received through all network interfaces on your computer during the time of the evaluation, together with the result of the evaluation. }, {, (RefLink[NetworkPacketTrace, paclet:ref/NetworkPacketTrace])[expr,service]
records only packets associated with the specified network service.}, {, (RefLink[NetworkPacketTrace, paclet:ref/NetworkPacketTrace])[expr,port]
records only packets associated with the specified port.}, {, (RefLink[NetworkPacketTrace, paclet:ref/NetworkPacketTrace])[expr,{(Subscript[port, 1]),(Subscript[port, 2]),…}]
records only packets associated with any of the ports (Subscript[port, i]).}, {, (RefLink[NetworkPacketTrace, paclet:ref/NetworkPacketTrace])[expr,spec]
records only packets matching the specification spec. }})

OpenersNotesSection(Spacer1)Details

(RefLink[NetworkPacketTrace, paclet:ref/NetworkPacketTrace]) has attribute (RefLink[HoldFirst, paclet:ref/HoldFirst]).

(RefLink[NetworkPacketTrace, paclet:ref/NetworkPacketTrace])[expr;] will give {packets,(RefLink[Null, paclet:ref/Null])}.

(RefLink[NetworkPacketTrace, paclet:ref/NetworkPacketTrace])[expr,…] records packets transmitted or received during the evaluation of expr, whether or not they are actually generated by the evaluation.

In (RefLink[NetworkPacketTrace, paclet:ref/NetworkPacketTrace])[…,service], possible forms for service include:

Entities can be entered using free-form linguistics with (Key1[ctrl, ==]).

In (RefLink[NetworkPacketTrace, paclet:ref/NetworkPacketTrace])[…,ports], network ports can be specified as follows:

In (RefLink[NetworkPacketTrace, paclet:ref/NetworkPacketTrace])[…,spec], spec can be given in the form key->value, or as an association containing multiple keys and values. Possible keys include:

IP addresses can be given as strings or (RefLink[IPAddress, paclet:ref/IPAddress]) objects.

Possible values for the "Interface" key can be any element in (RefLink[$NetworkInterfaces, paclet:ref/$NetworkInterfaces]), a list of these or (RefLink[All, paclet:ref/All]).

Any setting given for "PCAPFilter" overrides all other settings.

On Windows computers, (RefLink[SystemInstall, paclet:ref/SystemInstall])["WinPcap"] may be needed before (RefLink[NetworkPacketTrace, paclet:ref/NetworkPacketTrace]) is used.

(RefLink[NetworkPacketTrace, paclet:ref/NetworkPacketTrace]) typically requires elevated permissions on Linux and Mac.

OpenersPrimaryExamplesSection(Spacer1)Examples  (3)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Record all network packets during a (RefLink[WolframAlpha, paclet:ref/WolframAlpha]) call:

NetworkPacketTrace[WolframAlpha["data packets"]]

Capture all HTTP packets during a (RefLink[URLRead, paclet:ref/URLRead]):

NetworkPacketTrace[URLRead["wolfram.com"],"HTTP"]

Record all packets on port 80 or 443:

NetworkPacketTrace[URLRead["wolfram.com"],{80,443}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[NetworkPacketRecording, paclet:ref/NetworkPacketRecording])  ▪  (RefLink[$NetworkInterfaces, paclet:ref/$NetworkInterfaces])  ▪  (RefLink[HostLookup, paclet:ref/HostLookup])  ▪  (RefLink[PingTime, paclet:ref/PingTime])  ▪  (RefLink[URLResponseTime, paclet:ref/URLResponseTime])  ▪  (RefLink[SocketConnect, paclet:ref/SocketConnect])  ▪  (RefLink[SystemInstall, paclet:ref/SystemInstall])  ▪  (RefLink[AudioRecord, paclet:ref/AudioRecord])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Tuning & Debugging, paclet:guide/TuningAndDebugging])}, {▪(RefLinkPlain[Network Programming, paclet:guide/NetworkProgramming])}, {▪(RefLinkPlain[Internet and Computer Systems Data, paclet:guide/InternetAndWebRelatedData])}})}})