Index: abi/include/abi/ipc/interfaces.h
===================================================================
--- abi/include/abi/ipc/interfaces.h	(revision f87ff8e62c7a8a010413c60997320386cd62f9a8)
+++ abi/include/abi/ipc/interfaces.h	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
@@ -201,4 +201,6 @@
 	INTERFACE_WNDMGT_CB =
 	    FOURCC_COMPACT('w', 'm', 'g', 't') | IFACE_EXCHANGE_SERIALIZE | IFACE_MOD_CALLBACK,
+	INTERFACE_PCAP_CONTROL =
+	    FOURCC_COMPACT('p', 'c', 't', 'l') | IFACE_EXCHANGE_SERIALIZE,
 } iface_t;
 
Index: uspace/app/meson.build
===================================================================
--- uspace/app/meson.build	(revision f87ff8e62c7a8a010413c60997320386cd62f9a8)
+++ uspace/app/meson.build	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
@@ -72,4 +72,5 @@
 	'nic',
 	'nterm',
+	'pcapctl',
 	'ofw',
 	'pci',
Index: uspace/app/pcapctl/doc/doxygroups.h
===================================================================
--- uspace/app/pcapctl/doc/doxygroups.h	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
+++ uspace/app/pcapctl/doc/doxygroups.h	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
@@ -0,0 +1,4 @@
+/** @addtogroup pcapctl pcapctl
+ * @brief Dump network packets
+ * @ingroup apps
+ */
Index: uspace/app/pcapctl/main.c
===================================================================
--- uspace/app/pcapctl/main.c	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
+++ uspace/app/pcapctl/main.c	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2023 Nataliia Korop
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup pcapctl
+ * @{
+ */
+/** @file pcapctl app
+ */
+
+#include <stdio.h>
+#include <str.h>
+#include <errno.h>
+
+#include "pcapctl_dump.h"
+
+#define NAME "pcapctl"
+
+#define LOGGER(msg, ...) \
+     fprintf(stderr, \
+         "[PCAP %s:%d]: " msg "\n", \
+         __FILE__, __LINE__, \
+         ##__VA_ARGS__\
+     )
+
+pcapctl_sess_t sess;
+
+static void start_dumping(const char *name)
+{
+	pcapctl_dump_start(name, &sess);
+}
+
+static void stop_dumping(void)
+{
+	pcapctl_dump_stop(&sess);
+}
+
+static void usage(const char *progname)
+{
+	fprintf(stderr, "Usage:\n");
+	fprintf(stderr, "  %s start <outfile>: Packets will be written to <outfile>\n", progname);
+	fprintf(stderr, "  %s stop: Dumping stops\n", progname);
+
+}
+
+int main(int argc, char *argv[])
+{
+	if (argc < 2) {
+		usage(argv[0]);
+		return 1;
+	} else {
+		errno_t rc = pcapctl_dump_init(&sess);
+		if (rc != EOK) {
+			fprintf(stderr, "Error initializing ...\n");
+			return 1;
+		}
+		if (str_cmp(argv[1], "start") == 0) {
+			if (argc != 3) {
+				usage(argv[0]);
+				return 1;
+			}
+			start_dumping(argv[2]);
+		} else if (str_cmp(argv[1], "stop") == 0) {
+			stop_dumping();
+			fprintf(stdout, "Dumping was stopped\n");
+			return EOK;
+		} else {
+			usage(argv[0]);
+			return 1;
+		}
+	}
+	return 0;
+}
+
+/** @}
+ */
Index: uspace/app/pcapctl/meson.build
===================================================================
--- uspace/app/pcapctl/meson.build	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
+++ uspace/app/pcapctl/meson.build	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
@@ -0,0 +1,29 @@
+#
+# Copyright (c) 2023 Nataliia Korop
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+deps = ['pcap']
+src = files('main.c')
Index: uspace/drv/nic/e1k/e1k.c
===================================================================
--- uspace/drv/nic/e1k/e1k.c	(revision f87ff8e62c7a8a010413c60997320386cd62f9a8)
+++ uspace/drv/nic/e1k/e1k.c	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
@@ -51,4 +51,6 @@
 #include "e1k.h"
 
+#include "pcapdump_iface.h"
+#include "pcap_iface.h"
 #define NAME  "e1k"
 
@@ -174,4 +176,8 @@
 	/** Lock for EEPROM access */
 	fibril_mutex_t eeprom_lock;
+
+	/** Interface for dumping packets */
+	pcap_iface_t pcapdump;
+
 } e1000_t;
 
@@ -1189,4 +1195,6 @@
 		if (frame != NULL) {
 			memcpy(frame->data, e1000->rx_frame_virt[next_tail], frame_size);
+			pcapdump_packet(&e1000->pcapdump, frame->data, frame->size);
+
 			nic_received_frame(nic, frame);
 		} else {
@@ -2203,4 +2211,13 @@
 		goto err_add_to_cat;
 
+	errno_t pcap_rc  = pcapdump_init(&e1000->pcapdump);
+
+	if (pcap_rc != EOK) {
+		printf("Failed creating pcapdump port\n");
+	}
+	rc = ddf_fun_add_to_category(fun, "pcap");
+	if (rc != EOK)
+		goto err_add_to_cat;
+
 	return EOK;
 
@@ -2366,5 +2383,5 @@
 
 	memcpy(e1000->tx_frame_virt[tdt], data, size);
-
+	pcapdump_packet(&e1000->pcapdump, data, size);
 	tx_descriptor_addr->phys_addr = PTR_TO_U64(e1000->tx_frame_phys[tdt]);
 	tx_descriptor_addr->length = size;
Index: uspace/drv/nic/e1k/meson.build
===================================================================
--- uspace/drv/nic/e1k/meson.build	(revision f87ff8e62c7a8a010413c60997320386cd62f9a8)
+++ uspace/drv/nic/e1k/meson.build	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
@@ -27,4 +27,4 @@
 #
 
-deps = [ 'nic' ]
+deps = [ 'nic' , 'pcap' ]
 src = files('e1k.c')
Index: uspace/lib/c/include/ipc/services.h
===================================================================
--- uspace/lib/c/include/ipc/services.h	(revision f87ff8e62c7a8a010413c60997320386cd62f9a8)
+++ uspace/lib/c/include/ipc/services.h	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
@@ -67,5 +67,5 @@
 #define SERVICE_NAME_VBD      "vbd"
 #define SERVICE_NAME_VOLSRV   "volsrv"
-
+#define SERVICE_NAME_DUMPPCAP "dumppcap"
 #endif
 
Index: uspace/lib/meson.build
===================================================================
--- uspace/lib/meson.build	(revision f87ff8e62c7a8a010413c60997320386cd62f9a8)
+++ uspace/lib/meson.build	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
@@ -78,4 +78,5 @@
 	'minix',
 	'nettl',
+	'pcap',
 	'ofw',
 	'pcm',
Index: uspace/lib/pcap/doc/doxygoups.h
===================================================================
--- uspace/lib/pcap/doc/doxygoups.h	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
+++ uspace/lib/pcap/doc/doxygoups.h	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
@@ -0,0 +1,3 @@
+/** @addtogroup libpcap libpcap
+ * @ingroup libs
+ */
Index: uspace/lib/pcap/include/pcap.h
===================================================================
--- uspace/lib/pcap/include/pcap.h	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
+++ uspace/lib/pcap/include/pcap.h	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2023 Nataliia Korop
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @addtogroup libpcap
+ * @{
+ */
+/**
+ * @file
+ * @brief Headers and functions for .pcap file and packets to be dumped
+ */
+
+#ifndef PCAP_H_
+#define PCAP_H_
+
+#include <stdint.h>
+#include <stdio.h>
+#include <str_error.h>
+#include <time.h>
+#include <stdbool.h>
+#include <errno.h>
+
+#define PCAP_MAGIC_MICRO 0xA1B2C3D4
+#define PCAP_MAGIC_NANO 0xA1B23C4D
+#define PCAP_MAJOR_VERSION 0x0002
+#define PCAP_MINOR_VERSION 0x0004
+#define PCAP_SNAP_LEN 0x00040000
+
+#define PCAP_LINKTYPE_ETHERNET 1    /* IEEE 802.3 Ethernet*/
+
+/** Header of the .pcap file
+ */
+typedef struct {
+	uint32_t magic_number;
+	uint16_t major_v;
+	uint16_t minor_v;
+	uint32_t reserved1;
+	uint32_t reserved2;
+	uint32_t snaplen;
+	uint32_t additional; /** The LinkType and additional information field is in the form */
+} __attribute__((packed, aligned(4))) pcap_file_header_t;
+
+typedef struct pcap_packet_header {
+	uint32_t seconds_stamp;
+	uint32_t magic_stamp;
+	uint32_t captured_length;
+	uint32_t original_length;
+} pcap_packet_header_t;
+
+typedef struct pcap_writer pcap_writer_t;
+
+typedef struct {
+	size_t (*write_u32)(struct pcap_writer *, uint32_t);
+	size_t (*write_u16)(struct pcap_writer *, uint16_t);
+	size_t (*write_buffer)(struct pcap_writer *, const void *, size_t);
+	void (*close)(struct pcap_writer *);
+
+} pcap_writer_ops_t;
+
+/** Interface for working with .pcap file
+ */
+typedef struct pcap_writer {
+	void *data;
+	pcap_writer_ops_t *ops;
+} pcap_writer_t;
+
+errno_t pcap_writer_to_file_init(pcap_writer_t *writer, const char *filename);
+
+extern void pcap_writer_add_header(pcap_writer_t *);
+extern void pcap_writer_add_packet(
+    pcap_writer_t *writer, const void *captured_packet, size_t size);
+
+extern void pcap_set_time(pcap_packet_header_t *header, bool nano);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/pcap/include/pcap_iface.h
===================================================================
--- uspace/lib/pcap/include/pcap_iface.h	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
+++ uspace/lib/pcap/include/pcap_iface.h	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2023 Nataliia Korop
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libpcap
+ * @{
+ */
+/** @file pcap interface
+ */
+
+#ifndef PCAP_IFACE_H_
+#define PCAP_IFACE_H_
+
+#include <errno.h>
+#include "pcap.h"
+
+typedef struct pcap_iface {
+	bool to_dump;
+	errno_t (*init)(const char *);
+	void (*add_packet)(const void *data, size_t size);
+	void (*fini)(void);
+} pcap_iface_t;
+
+extern void pcap_close_file(void);
+extern errno_t pcap_iface_init(pcap_iface_t *);
+extern errno_t pcap_init(const char *);
+extern void pcap_add_packet(const void *data, size_t size);
+
+#endif
+/** @}
+ */
Index: uspace/lib/pcap/include/pcapctl_dump.h
===================================================================
--- uspace/lib/pcap/include/pcapctl_dump.h	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
+++ uspace/lib/pcap/include/pcapctl_dump.h	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2023 Nataliia Korop
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @addtogroup libpcap
+ * @{
+ */
+/**
+ * @file
+ *
+ */
+
+#ifndef _PCAPCTL_DUMP_H_
+#define _PCAPCTL_DUMP_H_
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <async.h>
+#include <loc.h>
+#include <fibril_synch.h>
+
+typedef struct {
+	async_sess_t *sess;
+} pcapctl_sess_t;
+
+extern errno_t pcapctl_dump_init(pcapctl_sess_t *);
+extern errno_t pcapctl_dump_start(const char *, pcapctl_sess_t *);
+extern errno_t pcapctl_dump_stop(pcapctl_sess_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/pcap/include/pcapdump_iface.h
===================================================================
--- uspace/lib/pcap/include/pcapdump_iface.h	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
+++ uspace/lib/pcap/include/pcapdump_iface.h	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2023 Nataliia Korop
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @addtogroup libpcap
+ * @{
+ */
+/**
+ * @file
+ *
+ */
+
+#ifndef _PCAPDUMP_IFACE_H_
+#define _PCAPDUMP_IFACE_H_
+
+#include <errno.h>
+#include "pcap_iface.h"
+
+typedef enum {
+	PCAP_CONTROL_SET_START = IPC_FIRST_USER_METHOD,
+	PCAP_CONTROL_SET_STOP
+} pcap_request_t;
+
+extern errno_t pcapdump_init(pcap_iface_t *);
+extern void pcapdump_packet(pcap_iface_t *, const void *, size_t);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/pcap/meson.build
===================================================================
--- uspace/lib/pcap/meson.build	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
+++ uspace/lib/pcap/meson.build	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
@@ -0,0 +1,34 @@
+#
+# Copyright (c) 2023 Nataliia Korop
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+src = files(
+    'src/pcap.c',
+    'src/pcap_iface.c',
+    'src/pcapdump_iface.c',
+    'src/pcapctl_dump.c',
+)
Index: uspace/lib/pcap/src/pcap.c
===================================================================
--- uspace/lib/pcap/src/pcap.c	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
+++ uspace/lib/pcap/src/pcap.c	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2023 Nataliia Korop
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @addtogroup libpcap
+ * @{
+ */
+/**
+ * @file
+ * @brief Headers and functions for .pcap file and packets to be dumped
+ */
+
+#define LOGGER(msg, ...) \
+     fprintf(stderr, \
+         "[PCAP %s:%d]: " msg "\n", \
+         __FILE__, __LINE__, \
+         ##__VA_ARGS__\
+     )
+
+#include "pcap.h"
+
+/** Set time in seconds and microseconds for the packet header .
+ *
+ * @param header Header of the packet to be dumped.
+ *
+ */
+void pcap_set_time(pcap_packet_header_t *header, bool nano) // maybe without bool nano as nano is in pcapng
+{
+	time_t sec = time(NULL);
+	header->seconds_stamp = (uint32_t)sec;
+	header->magic_stamp = nano ? header->seconds_stamp / 1000000000 : header->seconds_stamp / 1000000;
+}
+
+/** Add pcap file header to the new .pcap file.
+ *
+ * @param writer
+ *
+ */
+void pcap_writer_add_header(pcap_writer_t *writer)
+{
+	pcap_file_header_t file_header = { PCAP_MAGIC_MICRO, PCAP_MAJOR_VERSION, PCAP_MINOR_VERSION,
+		0x00000000, 0x00000000, (uint32_t)PCAP_SNAP_LEN, (uint32_t)PCAP_LINKTYPE_ETHERNET };
+	writer->ops->write_buffer(writer, &file_header, sizeof(file_header));
+}
+
+/** Add packet to the .pcap file.
+ *
+ * @param writer
+ * @param captured_packet Packet to be dumped
+ * @param size Size of the captured packet
+ *
+ */
+void pcap_writer_add_packet(pcap_writer_t *writer, const void *captured_packet, size_t size)
+{
+	if (!writer->data)
+		return;
+	pcap_packet_header_t pcap_packet;
+	pcap_set_time(&pcap_packet, false);
+	pcap_packet.original_length = (uint32_t)size;
+
+	if (PCAP_SNAP_LEN < size) {
+		pcap_packet.captured_length = PCAP_SNAP_LEN;
+	} else {
+		pcap_packet.captured_length = size;
+	}
+	writer->ops->write_buffer(writer, &pcap_packet, sizeof(pcap_packet));
+	writer->ops->write_buffer(writer, captured_packet, pcap_packet.captured_length);
+
+}
+
+/** Initialize writing to .pcap file.
+ *
+ * @param writer    Interface for working with .pcap file
+ * @param filename  Name of the file for dumping packets
+ * @return          EOK on success or an error code
+ *
+ */
+errno_t pcap_writer_to_file_init(pcap_writer_t *writer, const char *filename)
+{
+	errno_t rc;
+	writer->data = fopen(filename, "a");
+	if (writer->data == NULL) {
+		rc = EINVAL;
+		LOGGER("Failed to create %s: %s.", filename, str_error(rc));
+		return rc;
+	}
+	pcap_writer_add_header(writer);
+
+	rc = EOK;
+	return rc;
+}
+
+/** @}
+ */
Index: uspace/lib/pcap/src/pcap_iface.c
===================================================================
--- uspace/lib/pcap/src/pcap_iface.c	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
+++ uspace/lib/pcap/src/pcap_iface.c	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2023 Nataliia Korop
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libpcap
+ * @{
+ */
+/** @file
+ *  @brief pcap inteface: Dumping interface for the device which packets we want to dump
+ */
+
+#include <errno.h>
+#include "pcap_iface.h"
+
+static size_t pcap_file_w32(pcap_writer_t *writer, uint32_t data)
+{
+	return fwrite(&data, 1, 4, (FILE *)writer->data);
+}
+
+static size_t pcap_file_w16(pcap_writer_t *writer, uint16_t data)
+{
+	return fwrite(&data, 1, 2, (FILE *)writer->data);
+}
+
+static size_t pcap_file_wbuffer(pcap_writer_t *writer, const void *data, size_t size)
+{
+	return fwrite(data, 1, size, (FILE *)writer->data);
+}
+
+static void pcap_file_close(pcap_writer_t *writer)
+{
+	fclose((FILE *)writer->data);
+}
+
+static pcap_writer_ops_t file_ops = {
+
+	.write_u32 = &pcap_file_w32,
+	.write_u16 = &pcap_file_w16,
+	.write_buffer = &pcap_file_wbuffer,
+	.close = &pcap_file_close
+};
+
+static pcap_writer_t pcap_writer = {
+	.ops = &file_ops,
+};
+
+errno_t pcap_init(const char *name)
+{
+	errno_t rc = pcap_writer_to_file_init(&pcap_writer, name);
+	return rc;
+}
+
+void pcap_add_packet(const void *data, size_t size)
+{
+	if (&pcap_writer.data == NULL)
+		return;
+	pcap_writer_add_packet(&pcap_writer, data, size);
+}
+
+void pcap_close_file()
+{
+	pcap_writer.ops->close(&pcap_writer);
+	pcap_writer.data = NULL;
+}
+
+/** Initialize interface for dumping packets
+ *
+ * @param iface Device dumping interface
+ *
+ */
+errno_t pcap_iface_init(pcap_iface_t *iface)
+{
+
+	iface->to_dump = false;
+	iface->add_packet = pcap_add_packet;
+	iface->init = pcap_init;
+	iface->fini = pcap_close_file;
+
+	return EOK;
+}
+
+/** @}
+ */
Index: uspace/lib/pcap/src/pcapctl_dump.c
===================================================================
--- uspace/lib/pcap/src/pcapctl_dump.c	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
+++ uspace/lib/pcap/src/pcapctl_dump.c	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2023 Nataliia Korop
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libpcap
+ * @{
+ */
+/** @file
+ * @brief Client side of the pcapctl. Functions are called from the app pcapctl
+ */
+
+#include <errno.h>
+#include <async.h>
+#include <str.h>
+#include <stdlib.h>
+
+#include "pcapctl_dump.h"
+#include "pcapdump_iface.h"
+
+/** Finish an async exchange on the pcapctl session
+ *
+ * @param exch  Exchange to be finished
+ */
+static void pcapctl_dump_exchange_end(async_exch_t *exch)
+{
+	async_exchange_end(exch);
+}
+
+errno_t pcapctl_dump_init(pcapctl_sess_t *sess)
+{
+	errno_t rc;
+	char *svc_name;
+	category_id_t pcap_cat;
+	size_t count;
+	service_id_t *pcap_svcs = NULL;
+
+	rc = loc_category_get_id("pcap", &pcap_cat, 0);
+	if (rc != EOK) {
+		printf("Error resolving category 'pcap'.\n");
+		return rc;
+	}
+
+	rc = loc_category_get_svcs(pcap_cat, &pcap_svcs, &count);
+	if (rc != EOK) {
+		printf("Error resolving list of pcap services.\n");
+		return rc;
+	}
+	assert((count > 0) && "TODO: not implemented when no services are available\n");
+
+	rc = loc_service_get_name(pcap_svcs[0], &svc_name); // Note: for now [0], because only one driver is in pcap_svcs and there is no need to find particular
+	if (rc != EOK) {
+		printf("Error getting service name.\n");
+		goto error;
+	}
+	printf("Using device: %s\n", svc_name);
+
+	async_sess_t *new_session = loc_service_connect(pcap_svcs[0], INTERFACE_PCAP_CONTROL, 0);
+	if (new_session == NULL) {
+		printf("Error connecting to service.\n");
+		rc =  EREFUSED;
+		goto error;
+	}
+	sess->sess = new_session;
+	rc = EOK;
+error:
+	free(pcap_svcs);
+	return rc;
+}
+
+/** Starting a new session for pcapctl
+ *
+ * @param name Name of the file to dump packets to
+ * @param sess session to start
+ * @return EOK on success or an error code
+ */
+errno_t pcapctl_dump_start(const char *name, pcapctl_sess_t *sess)
+{
+	errno_t rc;
+	async_exch_t *exch = async_exchange_begin(sess->sess);
+
+	size_t size = str_size(name);
+	aid_t req = async_send_0(exch, PCAP_CONTROL_SET_START, NULL);
+
+	rc = async_data_write_start(exch, (void *) name, size);
+
+	pcapctl_dump_exchange_end(exch);
+
+	if (rc != EOK) {
+		async_forget(req);
+		return rc;
+	}
+
+	errno_t retval;
+	async_wait_for(req, &retval);
+	return retval;
+}
+
+/** Finish current session for pcapctl
+ *
+ * @param sess Session to finish
+ * @return EOK on success or an error code
+ */
+errno_t pcapctl_dump_stop(pcapctl_sess_t *sess)
+{
+	errno_t rc;
+	async_exch_t *exch = async_exchange_begin(sess->sess);
+	rc = async_req_0_0(exch, PCAP_CONTROL_SET_STOP);
+
+	pcapctl_dump_exchange_end(exch);
+	return rc;
+}
+
+/** @}
+ */
Index: uspace/lib/pcap/src/pcapdump_iface.c
===================================================================
--- uspace/lib/pcap/src/pcapdump_iface.c	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
+++ uspace/lib/pcap/src/pcapdump_iface.c	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2023 Nataliia Korop
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @addtogroup libpcap
+ * @{
+ */
+/**
+ * @file
+ * @brief Server side of the pcapctl
+ */
+
+#include <async.h>
+#include <errno.h>
+#include <fibril_synch.h>
+
+#include "pcapdump_iface.h"
+
+FIBRIL_MUTEX_INITIALIZE(to_dump_mutex);
+
+static void pcapdump_start_srv(ipc_call_t *icall, pcap_iface_t *iface)
+{
+	char *data;
+	size_t size;
+	errno_t rc = async_data_write_accept((void **) &data, false, 0, 0, 0, &size);
+	if (rc != EOK) {
+		async_answer_0(icall, rc);
+		return;
+	}
+
+	/** When try to start when already started, close current and starts new */
+	if (iface->to_dump == true) {
+		iface->fini();
+	}
+	iface->init((const char *)data);
+
+	fibril_mutex_lock(&to_dump_mutex);
+	iface->to_dump = true;
+	fibril_mutex_unlock(&to_dump_mutex);
+
+	async_answer_0(icall, rc);
+}
+
+static void pcapdump_stop_srv(ipc_call_t *icall, pcap_iface_t *iface)
+{
+	/** If want to stop, when already stopped, do nothing */
+	if (iface->to_dump == false) {
+		async_answer_0(icall, EOK);
+		return;
+	}
+
+	fibril_mutex_lock(&to_dump_mutex);
+	iface->to_dump = false;
+	fibril_mutex_unlock(&to_dump_mutex);
+
+	iface->fini();
+	async_answer_0(icall, EOK);
+}
+
+static void pcapdump_conn(ipc_call_t *icall, void *arg)
+{
+	pcap_iface_t *iface = (pcap_iface_t *)arg;
+
+	assert((iface != NULL) && "pcapdump requires pcap interface\n");
+
+	/* Accept connection */
+	async_accept_0(icall);
+
+	while (true) {
+		ipc_call_t call;
+		async_get_call(&call);
+		sysarg_t method = ipc_get_imethod(&call);
+		if (!method) {
+			/* The other side has hung up */
+			async_answer_0(&call, EOK);
+			break;
+		}
+		switch (method) {
+		case PCAP_CONTROL_SET_START:
+			pcapdump_start_srv(&call, iface);
+			break;
+		case PCAP_CONTROL_SET_STOP:
+			pcapdump_stop_srv(&call, iface);
+			break;
+		default:
+			async_answer_0(&call, EINVAL);
+			break;
+		}
+	}
+}
+
+errno_t pcapdump_init(pcap_iface_t *iface)
+{
+	port_id_t port;
+	errno_t rc;
+
+	rc = pcap_iface_init(iface);
+
+	if (rc != EOK) {
+		printf("Failed creating pcap interface: %s", str_error(rc));
+		return rc;
+	}
+
+	rc = async_create_port(INTERFACE_PCAP_CONTROL,
+	    pcapdump_conn, iface, &port);
+	if (rc != EOK) {
+		return rc;
+	}
+	return EOK;
+}
+
+/** Dumping function for driver
+ *
+ * Called every time, the packet is sent/recieved by the device
+ *
+ * @param iface Dumping interface
+ * @param data The packet
+ * @param size Size of the packet
+ *
+ */
+void pcapdump_packet(pcap_iface_t *iface, const void *data, size_t size)
+{
+
+	if (iface == NULL) {
+		return;
+	}
+
+	if (!iface->to_dump) {
+		return;
+	}
+
+	iface->add_packet(data, size);
+}
+
+/** @}
+ */
Index: uspace/srv/locsrv/locsrv.c
===================================================================
--- uspace/srv/locsrv/locsrv.c	(revision f87ff8e62c7a8a010413c60997320386cd62f9a8)
+++ uspace/srv/locsrv/locsrv.c	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
@@ -1390,4 +1390,6 @@
 	categ_dir_add_cat(&cdir, cat);
 
+	cat = category_new("pcap");
+	categ_dir_add_cat(&cdir, cat);
 	return true;
 }
