LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-29-2021, 08:47 AM   #1
linxbee
Member
 
Registered: Jan 2020
Distribution: RHEL,CENTOS, Ubuntu
Posts: 52

Rep: Reputation: Disabled
Incoming and out Going Broadcasted network traffic


This question is with reference to Linux OS.

Does Linux maintain any data structures or internal proc file system to store the incoming and outgoing bytes that are transmitted through broadcast method only.

I looked at /sys/class/net/<if>/.., but could not find any.

Is there any way to capture this info for every second so that , I can use them to calculate used bandwidth of any given interface.
 
Old 07-29-2021, 05:36 PM   #2
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
The command ifconfig will display received and transmitted bytes and packets on each interface. Writing a simple script to poll those values will achieve what you want. There are also some tools available but I don't use them so don't have the details.

If you did a simple search for what you want you would find a lot of resources so you could choose what would work for your needs. We are not in the business of performing web searches for you.
 
Old 07-29-2021, 05:41 PM   #3
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,223

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Use sar.
 
Old 08-03-2021, 09:53 PM   #4
linxbee
Member
 
Registered: Jan 2020
Distribution: RHEL,CENTOS, Ubuntu
Posts: 52

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by computersavvy View Post
The command ifconfig will display received and transmitted bytes and packets on each interface. Writing a simple script to poll those values will achieve what you want. There are also some tools available but I don't use them so don't have the details.

If you did a simple search for what you want you would find a lot of resources so you could choose what would work for your needs. We are not in the business of performing web searches for you.
ifconfig is not really much helpful here, it displays only the broadcast address not actual statistics.

But I have found a way using tool called ethtool to display statistics
 
Old 08-03-2021, 09:55 PM   #5
linxbee
Member
 
Registered: Jan 2020
Distribution: RHEL,CENTOS, Ubuntu
Posts: 52

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by dugan View Post
Use sar.
I cannot use it because i need to bring it up for my machine which is not recommended for my case.
 
Old 08-03-2021, 10:01 PM   #6
linxbee
Member
 
Registered: Jan 2020
Distribution: RHEL,CENTOS, Ubuntu
Posts: 52

Original Poster
Rep: Reputation: Disabled
I can get the statistics using ethtool:

Code:
$ ethtool -S eth0
NIC statistics:
     rx_packets: 40171178
     tx_packets: 36111432
     rx_bytes: 38029543322
     tx_bytes: 43785062291
     rx_broadcast: 1651523
     tx_broadcast: 13
     rx_multicast: 83759
     tx_multicast: 76
For broadcast and multicast it does not say its bytes or packets.

Can anyone let me know what are those values actually, packets or bytes?
 
Old 08-04-2021, 12:37 AM   #7
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749
According to this, multicast is packets.
Broadcast statistics are not standard, dependent on the device driver.
There is a suggestion here that will show packets.

Last edited by allend; 08-04-2021 at 12:38 AM.
 
1 members found this post helpful.
Old 08-04-2021, 09:19 AM   #8
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Quote:
Originally Posted by linxbee View Post
ifconfig is not really much helpful here, it displays only the broadcast address not actual statistics.

But I have found a way using tool called ethtool to display statistics
Actually ifconfig does display communications quantity. See the part in bold here
Code:
wlp4s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.111  netmask 255.255.255.0  broadcast 192.168.2.255
        ether 68:1c:a2:06:2d:b2  txqueuelen 1000  (Ethernet)
        RX packets 9105811  bytes 8187490903 (7.6 GiB)
        RX errors 0  dropped 1  overruns 0  frame 0
        TX packets 4831071  bytes 1748974314 (1.6 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
True, it is a single value, not defined by time other than since the interface was last activated, but with readings taken at specified intervals (maybe in a database) it is easy to calculate the rate.

OTOH ethtool has many more features so good luck with it.
 
1 members found this post helpful.
Old 08-04-2021, 09:30 AM   #9
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
I really do not understand why you would be concerned with broadcast and multicast bits/bytes/packets since other than transmitted the machine has no control over that. Received and transmitted OTOH actually reflect the amount of data actually going over the interface.

While I don't remember the units for sure, I think it is packets. Those are packets that are generally received or transmitted when a device on the net needs to obtain an arp packet so it can send data directly to the target. Broadcast goes to all devices on the net, multicast goes to several but limited in scope.
 
Old 08-04-2021, 12:53 PM   #10
linxbee
Member
 
Registered: Jan 2020
Distribution: RHEL,CENTOS, Ubuntu
Posts: 52

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by computersavvy View Post
I really do not understand why you would be concerned with broadcast and multicast bits/bytes/packets since other than transmitted the machine has no control over that. Received and transmitted OTOH actually reflect the amount of data actually going over the interface.

While I don't remember the units for sure, I think it is packets. Those are packets that are generally received or transmitted when a device on the net needs to obtain an arp packet so it can send data directly to the target. Broadcast goes to all devices on the net, multicast goes to several but limited in scope.
We are actually setting some upper limit on each interface how much it should receive, exceeding that limit has to be handled so that we can detect broadcast storm or any other activity(which can be an attack etc..)
 
Old 08-04-2021, 06:22 PM   #11
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
I understand what you are asking for, but it seems that should be related to a rate rather than an absolute top value received/sent. If a user transfers a large file but does not exceed the capacity of the network or interface in the speed at which it transfers then that may be OK. A flood of smaller packets that may be a lot less data but received in a very short time may overwhelm the ability of the interface to respond. That is really what you appear to be concerned about and you may have to track the rate for packets as well as data in order to handle it properly.

This is similar to the many ways that have been devised of identifying and handling a DDOS attack.
 
Old 08-05-2021, 05:08 AM   #12
linxbee
Member
 
Registered: Jan 2020
Distribution: RHEL,CENTOS, Ubuntu
Posts: 52

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by computersavvy View Post
I understand what you are asking for, but it seems that should be related to a rate rather than an absolute top value received/sent.
This is where we can read the values in certain time period (for every 5 sec or so) take the diff of previous and current bytes, then convert them to appropriate kB's/Mb's as required then match with whatever threshold value.

Is that not enough, pls comment, am really new to this.
 
Old 08-05-2021, 10:47 AM   #13
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
That is what I anticipated according to your posts. There are a lot of already existing methods available. I found many with a search for "how to detect ddos attack" and "tools to detect ddos attack"

I have never played with it myself, but I think you really should set the trigger on packets and not on data (bytes) since as I mentioned earlier downloading a large file could transfer a lot of data in large packets in a short time but is in no way an attack. In fact, if the attacker is transferring a lot of data then you already have a broken system.

OTOH, most ddos attacks depend on overwhelming the ability of the system to respond to everything incoming so they use a flood of much smaller packets.

Last edited by computersavvy; 08-05-2021 at 10:55 AM.
 
Old 08-05-2021, 11:15 AM   #14
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,289

Rep: Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322
Quote:
Originally Posted by computersavvy
OTOH, most ddos attacks depend on overwhelming the ability of the system to respond to everything incoming so they use a flood of much smaller packets.
The one DDoS "method" I got anywhere close to was a dos .bat file, which everybody on some irc channel ran simultaneously. It just pinged the chosen address. I forbade my kids using it.
 
Old 08-05-2021, 11:29 AM   #15
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Quote:
Originally Posted by business_kid View Post
The one DDoS "method" I got anywhere close to was a dos .bat file, which everybody on some irc channel ran simultaneously. It just pinged the chosen address. I forbade my kids using it.
I remember that, called a "ping flood". I heard about it but refused to indulge, as you did. A normal ping waits for a response, a flood does not wait but sends out as fast as possible.

That is not even close to what is used today with all the bot nets (windows machines with back doors and trojans) that do the true distributed attacks by remote control from around the world and are capable of bringing down even massive systems.
 
  


Reply

Tags
linux, network, network interface



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Socket does not respond to broadcasted packets ! ArshDeep Linux - Kernel 3 01-22-2014 09:13 AM
Routing return traffic based on the NIC of the incoming traffic? adamk75 Linux - Networking 3 12-11-2011 04:27 AM
[SOLVED] broadcasted network (ssid) is showing as hidden (wicd-client) dh2k Slackware 4 12-14-2010 03:36 PM
Network traffic -- monitor my incoming and outgoing ports bskrakes Linux - Networking 5 04-02-2008 08:44 AM
workgroup not being broadcasted by samba TheOneAndOnlySM Linux - Networking 5 04-10-2004 09:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration