1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:48:11 +00:00

Kernel: Record network statistics and expose as JSON

This is comprised of five small changes:

* Keep a counter for tx/rx packets/bytes per TCP socket
* Keep a counter for tx/rx packets/bytes per network adapter
* Expose that data in /proc/net_tcp and /proc/netadapters
* Convert /proc/netadapters to JSON
* Fix up ifconfig to read the JSON from netadapters
This commit is contained in:
Conrad Pankoff 2019-08-08 12:32:35 +10:00 committed by Andreas Kling
parent 061c092fae
commit 7ed54d86d5
7 changed files with 88 additions and 20 deletions

View file

@ -117,6 +117,15 @@ void TCPSocket::send_tcp_packet(u16 flags, const void* payload, int payload_size
tcp_packet.ack_number());
#endif
m_adapter->send_ipv4(MACAddress(), peer_address(), IPv4Protocol::TCP, buffer.data(), buffer.size());
m_packets_out++;
m_bytes_out += buffer.size();
}
void TCPSocket::record_incoming_data(int size)
{
m_packets_in++;
m_bytes_in += size;
}
NetworkOrdered<u16> TCPSocket::compute_tcp_checksum(const IPv4Address& source, const IPv4Address& destination, const TCPPacket& packet, u16 payload_size)