mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:17:35 +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:
parent
061c092fae
commit
7ed54d86d5
7 changed files with 88 additions and 20 deletions
|
@ -60,8 +60,13 @@ public:
|
|||
void set_sequence_number(u32 n) { m_sequence_number = n; }
|
||||
u32 ack_number() const { return m_ack_number; }
|
||||
u32 sequence_number() const { return m_sequence_number; }
|
||||
u32 packets_in() const { return m_packets_in; }
|
||||
u32 bytes_in() const { return m_bytes_in; }
|
||||
u32 packets_out() const { return m_packets_out; }
|
||||
u32 bytes_out() const { return m_bytes_out; }
|
||||
|
||||
void send_tcp_packet(u16 flags, const void* = nullptr, int = 0);
|
||||
void record_incoming_data(int);
|
||||
|
||||
static Lockable<HashMap<IPv4SocketTuple, TCPSocket*>>& sockets_by_tuple();
|
||||
static TCPSocketHandle from_tuple(const IPv4SocketTuple& tuple);
|
||||
|
@ -85,6 +90,10 @@ private:
|
|||
u32 m_sequence_number { 0 };
|
||||
u32 m_ack_number { 0 };
|
||||
State m_state { State::Closed };
|
||||
u32 m_packets_in { 0 };
|
||||
u32 m_bytes_in { 0 };
|
||||
u32 m_packets_out { 0 };
|
||||
u32 m_bytes_out { 0 };
|
||||
};
|
||||
|
||||
class TCPSocketHandle : public SocketHandle {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue