LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 11-22-2005, 07:47 PM   #1
MQMan
Member
 
Registered: Jan 2004
Location: Los Angeles
Distribution: Slack64 14.1
Posts: 581

Rep: Reputation: 38
Are Broadcasts to 255.255.255.255 Routed


I'm writing a small application to emulate an "appliance" in order to run some testing without the physical device. This "appliance" starts off by broadcasting a "Hello I'm here" message, on UDP, every couple of seconds, waiting for a response. When I sniffed the network, I could see the broadcasts being sent to 192.168.0.255.

For my application, I didn't want to hardcode the address, so I tried to use 255.255.255.255, but this doesn't appear to go anywhere. A sniffer running on the same box doesn't even see the packets. To check my program, I hardcoded the address as "192.168.0.2555" and everything looks good.

So, two questions. Why doesn't broadcasting to "255.255.255.255" work. Or is there something else I need to set, in addition to SO_BROADCAST to get this to work.

And secondly, if I can't use 255's, then how can I determine, programatically, the address to use, as this my run on differently configured machines. And these will usually be Linux, but might also be WinBlows.

Cheers,
Eddie
 
Old 11-22-2005, 08:57 PM   #2
Draygo
Member
 
Registered: May 2004
Location: Frisco, TX
Distribution: Debian Unstable
Posts: 73

Rep: Reputation: 15
1. The reason that 255.255.255.255 doesn't work because it is not a valid broadcast address. Machines will only ever respond to requests directed at it or directed at it's broadcast address.

2. Two suggestions to determine the addresses. One is to use dhcp to configure your applicance. This is the most simple as your appliance will basically auto configure itself. Second would be to sniff the traffic and after getting a good enough sample of source and destination addresses you can determine the network.
 
Old 11-23-2005, 03:11 AM   #3
MQMan
Member
 
Registered: Jan 2004
Location: Los Angeles
Distribution: Slack64 14.1
Posts: 581

Original Poster
Rep: Reputation: 38
Quote:
2. Two suggestions to determine the addresses. One is to use dhcp to configure your applicance. This is the most simple as your appliance will basically auto configure itself. Second would be to sniff the traffic and after getting a good enough sample of source and destination addresses you can determine the network.
That's not quite was I was after. Neither of those are "programatic" ways that an application can determine what broadcast address to use.

Cheers,
Eddie
 
Old 11-23-2005, 03:55 AM   #4
Draygo
Member
 
Registered: May 2004
Location: Frisco, TX
Distribution: Debian Unstable
Posts: 73

Rep: Reputation: 15
I guess what you can do is use a dhcp library to go through the motions of dhcp and then release the address. This will give you all the information you would need.
 
Old 11-23-2005, 07:04 AM   #5
fur
Member
 
Registered: Dec 2003
Distribution: Debian, FreeBSD
Posts: 310

Rep: Reputation: 35
The broadcast address shows up in ifconfig's output.. You could have the script execute that command, then with sed/awk you should be able to grab it out, and assign it to a variable for later use.
 
Old 11-23-2005, 08:20 AM   #6
farslayer
LQ Guru
 
Registered: Oct 2005
Location: Northeast Ohio
Distribution: linuxdebian
Posts: 7,249
Blog Entries: 5

Rep: Reputation: 191Reputation: 191
x.x.x.0 in a /24 network is the Network address it should NEVER be assigned to a host.
x.x.x.255 in a /24 network is the broadcast address, it should never be assigned to a host...

/24 means a 24 bit subnet mask or 255.255.255.0


/24 = 255.255.255.0 = 11111111.11111111.11111111.00000000

You would need to make the last portion of the IP address 255 ( eight 1's..) for it to be the broadcast..

so if the network is 192.168.1.0 /24 the broadcast address should be 192.168.1.255
if the network is 172.16.14.0 /24 the broadcast address would be 172.16.14.255


/16 = 255.255.0.0 = 11111111.11111111.00000000.00000000

For this one you need to replace the last 2 octets with 255..

if the network address is 172.16.0.0 /16 the broadcast address would be 172.16.255.255

do you see the patern here ? take the subnet mask replace the 0's with 1's and you have the broadcast address for the network..


/22 = 255.255.224.0 = 11111111.11111111.11111100.00000000

192.168.4.0 /22 boradcast address = 192.168.7.255 simple binary math..
http://jodies.de/ipcalc?host=192.168...ask1=22&mask2=



do a bit of reading on subnetting and this should become really clear.. my explaination ermmm may not be so clear to you as it appears to me
 
Old 11-23-2005, 02:16 PM   #7
MQMan
Member
 
Registered: Jan 2004
Location: Los Angeles
Distribution: Slack64 14.1
Posts: 581

Original Poster
Rep: Reputation: 38
Thanks, but none of this really helps.

Draygo: It looks like the 255.255.255.255 broadcasts are being sent through my local network. My problem was, that my Linux box has 2 NICs, and I suspect that they were being routed down the "wrong" one. When I ran the application on Windows, the broadcasts were visible at the Linux box. So, the following 2 comments are kinda not needed, but I wanted to put the record straight.

farslayer: I already do understand how IPs, subnets, broadcast address, gateway, etc. My problem is, how to get that information in an application on a running system.

fur: Did you notice that I asked for a "portable" way of doing this. This needs to run on Windows as well. And also, I did say "application", not script.

Cheers,
Eddie

Last edited by MQMan; 11-23-2005 at 05:28 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Logs full of hits to 255.255.255.255; how to stop logging? mac_phil Mandriva 2 02-23-2004 10:25 AM
dhcp subnet is 255.255.252.0 why does dhclient not find it???? baked Linux - Wireless Networking 0 01-06-2004 08:25 AM
UDP broadcast 255.255.255.255 java8964 Linux - Networking 0 10-29-2003 02:05 PM
getting to an ip in 255.255.252.0 phishman3579 Linux - Networking 3 09-17-2003 02:56 PM
configuring RH 7 for a subnet mask of 255.255.255.224 CDPL Linux - Networking 2 04-20-2002 09:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:53 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