How to send the data over broadcast address?

2

I am trying to play around with networks. I can see the following information of my pc.

# ifconfig
em1       Link encap:Ethernet  HWaddr B8:CA:3A:89:EE:F1  
          inet addr:136.170.195.17  Bcast:136.170.195.255  Mask:255.255.252.0
          inet6 addr: fe80::baca:3aff:fe89:eef1/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2451527 errors:0 dropped:0 overruns:0 frame:0
          TX packets:465326 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:348889561 (332.7 MiB)  TX bytes:308284135 (294.0 MiB)
          Interrupt:20 Memory:f7e00000-f7e20000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:186285 errors:0 dropped:0 overruns:0 frame:0
          TX packets:186285 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:44085804 (42.0 MiB)  TX bytes:44085804 (42.0 MiB)

p3p1      Link encap:Ethernet  HWaddr CC:B2:55:BA:B6:A4  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

Now, I want to broadcast a data over network. So, that I can check on the other pc's whether they received my message or not? How can I do so? How can I experiment by sending data over broadcast address? What is the utility to send data over broadcast address? This is actually to clear my fundamentals.

dexterous

Posted 2014-02-11T07:21:10.600

Reputation: 181

Answers

2

Use http://www.dest-unreach.org/socat/, both for sending and receiving. Look at the examples page for inspiration ( http://www.dest-unreach.org/socat/doc/socat.html#EXAMPLES ):

socat - UDP4-DATAGRAM:224.255.0.1:6666,bind=:6666,ip-add-membership=224.255.0.1:eth0 transfers data from stdin to the specified multicast address using UDP. Both local and remote ports are 6666. Tells the interface eth0 to also accept multicast packets of the given group. Multiple hosts on the local network can run this command, so all data sent by any of the hosts will be received by all the other ones. Note that there are many possible reasons for failure, including IP-filters, routing issues, wrong interface selection by the operating system, bridges, or a badly configured switch.

akira

Posted 2014-02-11T07:21:10.600

Reputation: 52 754

How about netstat? How can I do so with netstat? – dexterous – 2014-02-11T08:37:20.147

netstat is for showing the stats of the network, hence the name. it's not for moving data. did you mean "netcat"? – akira – 2014-02-11T08:40:24.257

Does netcat broadcast the data? – dexterous – 2014-02-11T08:45:51.343

1http://linux.die.net/man/1/nc – akira – 2014-02-11T08:46:47.010