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.


records only packets associated with the specified network service.


records only packets associated with the specified port.


records only packets associated with any of the ports porti.


records only packets matching the specification spec.


  • NetworkPacketTrace has attribute HoldFirst.
  • NetworkPacketTrace[expr;] will give {packets,Null}.
  • NetworkPacketTrace[expr,] records packets transmitted or received during the evaluation of expr, whether or not they are actually generated by the evaluation.
  • In NetworkPacketTrace[,service], possible forms for service include:
  • "name"an IANA named service (e.g. "HTTP")
    entityan entity of type "NetworkService"
  • Entities can be entered using free-form linguistics with .
  • In NetworkPacketTrace[,ports], network ports can be specified as follows:
  • nsingle port number n
    nmin;;nmaxa range of ports from nmin to nmax
    {n1,n2,}a list of ports
  • In NetworkPacketTrace[,spec], spec can be given in the form keyvalue, or as an association containing multiple keys and values. Possible keys include:
  • "IPAddress"source or destination IP address
    "SourceIPAddress"source IP address
    "DestinationIPAddress"destination IP address
    "IPAddressType"source or destination IP address type (e.g. "IPv4" or "IPv6")
    "SourceIPAddressType"source IP address type
    "DestinationIPAddressType"destination IP address type
    "Port"source or destination port
    "SourcePort"source port
    "DestinationPort"destination port
    "Interface"network interface (e.g. "en0")
    "PCAPFilter"raw PCAP filter specification as a string
  • IP addresses can be given as strings or IPAddress objects.
  • Possible values for the "Interface" key can be any element in $NetworkInterfaces, a list of these or All.
  • Any setting given for "PCAPFilter" overrides all other settings.
  • On Windows computers, SystemInstall["WinPcap"] may be needed before NetworkPacketTrace is used.
  • NetworkPacketTrace typically requires that the Wolfram kernel be run with elevated permissions (e.g. as root) on Linux and Mac.


Basic Examples  (3)

Record all network packets during a WolframAlpha call:

Capture all HTTP packets during a URLRead:

Record all packets on port 80 or 443:

Wolfram Research (2019), NetworkPacketTrace, Wolfram Language function,


Wolfram Research (2019), NetworkPacketTrace, Wolfram Language function,


Wolfram Language. 2019. "NetworkPacketTrace." Wolfram Language & System Documentation Center. Wolfram Research.


Wolfram Language. (2019). NetworkPacketTrace. Wolfram Language & System Documentation Center. Retrieved from


@misc{reference.wolfram_2024_networkpackettrace, author="Wolfram Research", title="{NetworkPacketTrace}", year="2019", howpublished="\url{}", note=[Accessed: 14-June-2024 ]}


@online{reference.wolfram_2024_networkpackettrace, organization={Wolfram Research}, title={NetworkPacketTrace}, year={2019}, url={}, note=[Accessed: 14-June-2024 ]}