NetworkPacketRecording

NetworkPacketRecording[t]

records information on network packets transmitted or received through all network interfaces on your computer for t seconds.

NetworkPacketRecording[t,service]

records only packets associated with the specified network service.

NetworkPacketRecording[t,port]

records only packets associated with the specified port.

NetworkPacketRecording[t,{port1,port2,}]

records only packets associated with any of the ports porti.

NetworkPacketRecording[t,spec]

records only packets matching the specification spec.

Details

  • t can be a number of seconds or a Quantity object representing the time to record for.
  • In NetworkPacketRecording[,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 NetworkPacketRecording[,ports], network ports can specified as follows:
  • nsingle port number n
    nmin;;nmaxa range of ports from nmin to nmax
    {n1,n2,}a list of ports
  • In NetworkPacketRecording[,spec], spec can be given in the form key->value, 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 NetworkPacketRecording is used.
  • NetworkPacketRecording typically requires elevated permissions on Linux and Mac.

Examples

open allclose all

Basic Examples  (5)

Record all network activity for two seconds:

In[1]:=
Click for copyable input
Out[1]=

Record all HTTP packets for two seconds:

In[1]:=
Click for copyable input
Out[1]=

Record all network activity on port 80:

In[1]:=
Click for copyable input
Out[1]=

Record all network activity on a specific network interface:

In[1]:=
Click for copyable input
Out[1]=

Record packets using a direct PCAP filter string:

In[1]:=
Click for copyable input
Out[1]=

Scope  (1)

See Also

NetworkPacketCapture  $NetworkInterfaces  $DefaultNetworkInterface  HostLookup  PingTime  URLResponseTime  SocketListen  SystemInstall  DeviceReadTimeSeries

Introduced in 2018
(11.3)