SDL_net and broadcasting

Hello.

**My motivations
I’m currently working on a great GPL game, “globulation2”, aviable on
savanah.
Thatfor, I need broadcasting ability in the LAN or subnet. (sening to ip
255.255.255.255)
But SDL_net does not provide the abitity to send packet to ip
255.255.255.255.
Therefore, I programmed a UNIX C++ object to allow easy broadcasing, and
it’s working fine on GNU/Linux.
(But I have some header/#define trouble on macosX and Solaris, fixed by
changing the makefile.)
Therefor it would be nicer to implements broadcasting info SDL, and
everyone could use it !

**My questions
Is anyone else interested in the broadcasting ability ?
How would you like broadcasting ability to be implemented in SDL_Net ?
Who know about OpenTransport and broadcasting ?
Who is the SDL_net responsible ?

**Technical considerations
I know about UNIX over IP programming, but not OpenTransport at all.
The problem is that you have to change the “socketDefinition” to allow
broadcasting.
This corresponds to “UDPsocket” in SDL_net.
Then I see two possiblilities:

1)Change the
UDPsocket SDLNet_UDP_Open(Uint16 port)
to
UDPsocket SDLNet_UDP_Open(Uint16 port, int broadcast)
This is cleaner toward UNIX way to see broadcast, but we loose backward
compatiblity.

2)We dynamicaly changes the SocketDefinition’s flags before and after
sending the UDP packet.
This would looks like: this is only the idea)

#define INADDR_BROADCASTING 0xFFFFFFFF
if (packets[i]->address.host=INADDR_BROADCASTING)
{
int socketDefinition=sock->channel;
char ttl=1;
setsockopt(socketDefinition, IPPROTO_IP, IP_MULTICAST_TTL, &ttl,
sizeof(ttl));
int hold=1;
setsockopt(socketDefinition, SOL_SOCKET, SO_BROADCAST, &hold,
sizeof(hold));
}

// more the recovering part after sending

**Who will do the work
If any choice is made, can programm the UNIX part of it.
But i’m looking for someone to do it for OpenTransport.

Thanks!

Luc-Olivier de Charri?re

Hello.

**My motivations
I’m currently working on a great GPL game, “globulation2”, aviable on
savanah.
Thatfor, I need broadcasting ability in the LAN or subnet. (sening to ip
255.255.255.255)
But SDL_net does not provide the abitity to send packet to ip
255.255.255.255.
Therefore, I programmed a UNIX C++ object to allow easy broadcasing, and
it’s working fine on GNU/Linux.
(But I have some header/#define trouble on macosX and Solaris, fixed by
changing the makefile.)
Therefor it would be nicer to implements broadcasting info SDL, and
everyone could use it !

**My questions
Is anyone else interested in the broadcasting ability ?
How would you like broadcasting ability to be implemented in SDL_Net ?
Who know about OpenTransport and broadcasting ?
Who is the SDL_net responsible ?

**Technical considerations
I know about UNIX over IP programming, but not OpenTransport at all.
The problem is that you have to change the “socketDefinition” to allow
broadcasting.
This corresponds to “UDPsocket” in SDL_net.
Then I see two possiblilities:

1)Change the
UDPsocket SDLNet_UDP_Open(Uint16 port)
to
UDPsocket SDLNet_UDP_Open(Uint16 port, int broadcast)
This is cleaner toward UNIX way to see broadcast, but we loose backward
compatiblity.

2)We dynamicaly changes the SocketDefinition’s flags before and after
sending the UDP packet.
This would looks like: this is only the idea)

#define INADDR_BROADCASTING 0xFFFFFFFF
if (packets[i]->address.host=INADDR_BROADCASTING)
{
int socketDefinition=sock->channel;
char ttl=1;
setsockopt(socketDefinition, IPPROTO_IP, IP_MULTICAST_TTL, &ttl,
sizeof(ttl));
int hold=1;
setsockopt(socketDefinition, SOL_SOCKET, SO_BROADCAST, &hold,
sizeof(hold));
}

// more the recovering part after sending

**Who will do the work
If any choice is made, can programm the UNIX part of it.
But i’m looking for someone to do it for OpenTransport.

Thanks!

Luc-Olivier de Charri?re_______________________________________________
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hello.

**My motivations
I’m currently working on a great GPL game, “globulation2”, aviable on
savanah.
Thatfor, I need broadcasting ability in the LAN or subnet. (sening to
ip 255.255.255.255)
But SDL_net does not provide the abitity to send packet to ip
255.255.255.255.

IIRC, anything ending in .255 is a broadcast address. If your subnet is
128.0.0, sending to 128.0.0.255 should broadcast to the entire network

  • assuming the network allows IP broadcast.

However, I don’t know if this will work with SDL_net. You may have to
use a UDP packet instead of TCP.

-DOn Friday, September 27, 2002, at 02:04 PM, Luc-Olivier de Charri?re wrote:

Hello.

**My motivations
I’m currently working on a great GPL game, “globulation2”, aviable on
savanah.
Thatfor, I need broadcasting ability in the LAN or subnet. (sening to
ip 255.255.255.255)
But SDL_net does not provide the abitity to send packet to ip
255.255.255.255.

IIRC, anything ending in .255 is a broadcast address. If your subnet is
128.0.0, sending to 128.0.0.255 should broadcast to the entire network

  • assuming the network allows IP broadcast.

However, I don’t know if this will work with SDL_net. You may have to
use a UDP packet instead of TCP.

SDL_net provides UDP packets, and yes, I believe Darrell is correct.
Does Linux require extra work to send to the broadcast addresses?

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment> On Friday, September 27, 2002, at 02:04 PM, Luc-Olivier de Charri?re wrote:

1)Change the
UDPsocket SDLNet_UDP_Open(Uint16 port)
to
UDPsocket SDLNet_UDP_Open(Uint16 port, int broadcast)
This is cleaner toward UNIX way to see broadcast, but we loose backward
compatiblity.

in response to that you could do this to maintain backwards compatibility
couldnt you?

UDPsocket SDLNet_UDP_Open(Uint16 port, int broadcast=0)> ----- Original Message -----

From: nuage@ysagoon.com (Nuage)
To:
Sent: Sunday, September 29, 2002 4:47 PM
Subject: [SDL] SDL_net and broadcasting

Hello.

**My motivations
I’m currently working on a great GPL game, “globulation2”, aviable on
savanah.
Thatfor, I need broadcasting ability in the LAN or subnet. (sening to ip
255.255.255.255)
But SDL_net does not provide the abitity to send packet to ip
255.255.255.255.
Therefore, I programmed a UNIX C++ object to allow easy broadcasing, and
it’s working fine on GNU/Linux.
(But I have some header/#define trouble on macosX and Solaris, fixed by
changing the makefile.)
Therefor it would be nicer to implements broadcasting info SDL, and
everyone could use it !

**My questions
Is anyone else interested in the broadcasting ability ?
How would you like broadcasting ability to be implemented in SDL_Net ?
Who know about OpenTransport and broadcasting ?
Who is the SDL_net responsible ?

**Technical considerations
I know about UNIX over IP programming, but not OpenTransport at all.
The problem is that you have to change the “socketDefinition” to allow
broadcasting.
This corresponds to “UDPsocket” in SDL_net.
Then I see two possiblilities:

1)Change the
UDPsocket SDLNet_UDP_Open(Uint16 port)
to
UDPsocket SDLNet_UDP_Open(Uint16 port, int broadcast)
This is cleaner toward UNIX way to see broadcast, but we loose backward
compatiblity.

2)We dynamicaly changes the SocketDefinition’s flags before and after
sending the UDP packet.
This would looks like: this is only the idea)

#define INADDR_BROADCASTING 0xFFFFFFFF
if (packets[i]->address.host=INADDR_BROADCASTING)
{
int socketDefinition=sock->channel;
char ttl=1;
setsockopt(socketDefinition, IPPROTO_IP, IP_MULTICAST_TTL, &ttl,
sizeof(ttl));
int hold=1;
setsockopt(socketDefinition, SOL_SOCKET, SO_BROADCAST, &hold,
sizeof(hold));
}

// more the recovering part after sending

**Who will do the work
If any choice is made, can programm the UNIX part of it.
But i’m looking for someone to do it for OpenTransport.

Thanks!

Luc-Olivier de Charri?re


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

in response to that you could do this to maintain backwards compatibility
couldnt you?

UDPsocket SDLNet_UDP_Open(Uint16 port, int broadcast=0)

That would retain source level compatibiliy but not binary level
compatibiliy.

IIRC, anything ending in .255 is a broadcast address. If your subnet is
128.0.0, sending to 128.0.0.255 should broadcast to the entire network

  • assuming the network allows IP broadcast.

However, I don’t know if this will work with SDL_net. You may have to
use a UDP packet instead of TCP.

TCP is a connected transmission protocol, one socket to one socket.
Then you can’t have any broadasting ability with TCP. (only multicasting
but this is something totally different we won’t talk about)
So you can only broadcast with UDP packets.

yes, any address ending with .255 is a broadcasting address.

SDL_net provides UDP packets, and yes, I believe Darrell is correct.
Does Linux require extra work to send to the broadcast addresses?

Yes you need extra work, somhow.
You can’t simply send packets to a broadcasting address. This will fail.
A SDL_net example:

void f(int size, void *data)
{
UDPpacket *packet=SDLNet_AllocPacket(size);
assert(packet);
memcpy((char *)packet->data, data, size);

packet->address.host=0xFFFFFFFF;
packet->address.port=0;
packet->channel=-1;

bool success=SDLNet_UDP_Send(socket, channel, packet)==1;

printf("success=%d", success);

}

success=0

Or a UNIX example:

{
// servAddr has been set to 255.255.255.255
int rc=sendto(socketDefinition, data, size, 0, (struct sockaddr *)
&servAddr, sizeof(servAddr));
if (rc<0)
printf(“failed”);
}

failed

You have to modiffy the “socketDefinition” this way:
(“sock->channel” into SDLnetUDP.c)

char ttl=1;
setsockopt(socketDefinition, IPPROTO_IP, IP_MULTICAST_TTL, &ttl,
sizeof(ttl));
int hold=1;
setsockopt(socketDefinition, SOL_SOCKET, SO_BROADCAST, &hold, sizeof(hold));

OK, setting TTL=1 is obviously optional, but cleaner.
But the second modiffication is mandatory for broadcasting.

Once it’s accepeted, we have to come back to my fist mail: how to
implements this ?

Luc-Olivier de Charri?re

nuage wrote:

yes, any address ending with .255 is a broadcasting address.

is this really true? i think not. it depends on your subnetting. the
broadcast address is the one with all host bits set.

i use binary notation to make it clear:

netmask: 11111111.11111111.11111111.11110000
network: 00001101.11001100.01010101.00110000
ip: 00001101.11001100.01010101.00110001
broadcast: 00001101.11001100.01010101.00111111

any address ending with 255 is a broadcast address in class C networks
(netmask: XXX.XXX.XXX.0).

i hope i didn’t mess something up. :slight_smile:

regards …
clemens

You are correct… a broadcast address is (by convention) any address
where the IP address bitwise-ORed with its netmask is 255.255.255.255…
like- wise, the conventional network and gateway addresses have similar
definitions. Unfortunatly, these are appearantly just conventions, and
can be changed at the whim of the network administrator…

So, YMMV…

:expressionless:

-LorenOn Mon, 2002-09-30 at 09:43, Clemens Kirchgatterer wrote:

nuage wrote:

yes, any address ending with .255 is a broadcasting address.

is this really true? i think not. it depends on your subnetting. the
broadcast address is the one with all host bits set.

i use binary notation to make it clear:

netmask: 11111111.11111111.11111111.11110000
network: 00001101.11001100.01010101.00110000
ip: 00001101.11001100.01010101.00110001
broadcast: 00001101.11001100.01010101.00111111

any address ending with 255 is a broadcast address in class C networks
(netmask: XXX.XXX.XXX.0).

i hope i didn’t mess something up. :slight_smile:

regards …
clemens

yes, any address ending with .255 is a broadcasting address.

is this really true? i think not. it depends on your subnetting. the
broadcast address is the one with all host bits set.

i use binary notation to make it clear:

netmask: 11111111.11111111.11111111.11110000
network: 00001101.11001100.01010101.00110000
ip: 00001101.11001100.01010101.00110001
broadcast: 00001101.11001100.01010101.00111111

any address ending with 255 is a broadcast address in class C networks
(netmask: XXX.XXX.XXX.0).

i hope i didn’t mess something up. :slight_smile:

You are right.
Therefore, we can’t auto-detect if the destination IP is a broadcasting,
without the subnet mask.
Now SDL_net don’t support any broadcasting, but we can do a bit better.

I suggest:
We only support 255.255.255.255
This is easy, and work most of the time. There is no assertion on the
network mask. We can keep all compatibility.
This way to broadcast should never be forwarded by router, and allways work.

Yes, it’s not perfect, it’s simply better than now.
We wouldn’t support 192.168.1.255-like broadcasting IPs.
In this case, simply send to 255.255.255.255, this will do the same.
Except if you have two subnets and your router worward 192.168.1.255,
but not 255.255.255.255, for security purpose maybe.
But
-how many router route broadcasting IP ?
-if this still exists, I can’t see any usefull application of this
feature. (or this is so rare!)

hi

Luc-Olivier de Charri?re

I suggest:
We only support 255.255.255.255
This is easy, and work most of the time. There is no assertion on the
network mask. We can keep all compatibility.

Sounds good to me.

But
-how many router route broadcasting IP ?

Routers don’t route LAN broadcast packets, by definition.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Sam Lantinga wrote:

I suggest: We only support 255.255.255.255
This is easy, and work most of the time. There is no assertion on
the network mask. We can keep all compatibility.

-how many router route broadcasting IP ?

Routers don’t route LAN broadcast packets, by definition.

hmm, but how does the router know thats a LAN broadcast? AFAIK,
255.255.255.255 broadcasts to the hole internet. or do you mean that a
router never routes any 255.255.255.255 broadcast (of course, if not
told otherwise). i would expect my ISP to throw away 255.255.255.255
broadcasts, though. :slight_smile:

I suggest:
We only support 255.255.255.255
This is easy, and work most of the time. There is no assertion on the
network mask. We can keep all compatibility.

Sounds good to me.

OK, messages received. Then I’ll start working on it.
Let’s summarize:
I add only 255.255.255.255 support to SDL_Net, with dynamic
modiffication of the SocketDefinition.
That will simply be better, and we will keep the code and binary
compatibility.

Who does I send the final code to ?
(I’ll be on holidays next week, but I’ll finish it soon anyways)

But
-how many router route broadcasting IP ?

Routers don’t route LAN broadcast packets, by definition.

Not really. But we can assume thoses cases to be "over-specific"
compared to SDL.

Routers don’t route LAN broadcast packets, by definition.

hmm, but how does the router know thats a LAN broadcast? AFAIK,
255.255.255.255 broadcasts to the hole internet. or do you mean that a
router never routes any 255.255.255.255 broadcast (of course, if not
told otherwise). i would expect my ISP to throw away 255.255.255.255
broadcasts, though. :slight_smile:

The domain administrator has to configure all thoses things.
I don’t know if it’s allowed to route a 255.255.255.255 packet. I don’t
know any router who do that.
Probably that at the beginning of internet, the 255.255.255.255 did
meant to broadcast the whole internet.
Of course, now, to avoid a global internet congestion, thoses packets
are automatically dropped by routers!
Then, the semantic has changed, and now the 255.255.255.255 adresse
simply means “broadcasting to the LAN only”.
I don’t know it it’s official, I don’t know how decides that. But I’m
sure that’s works.

The domain administrator has to configure all thoses things.
I don’t know if it’s allowed to route a 255.255.255.255 packet. I don’t
know any router who do that.
Probably that at the beginning of internet, the 255.255.255.255 did
meant to broadcast the whole internet.
Of course, now, to avoid a global internet congestion, thoses packets
are automatically dropped by routers!
Then, the semantic has changed, and now the 255.255.255.255 adresse
simply means “broadcasting to the LAN only”.
I don’t know it it’s official, I don’t know how decides that. But I’m
sure that’s works.

Who get’s the broadcast is a matter of how the netmask is set up,
if you have say, 255.255.255.0 in netmask you will send the broadcast
to 192.168.your_subnet_nr.1-254.