UDP buffer space

J

Janko Nedic

I am trying to write an application that simulates a router.
The problem I have is, that at some point during the execution
I need to know how much free space is there on a socket's buffer.
The socket is, Java's standard UDP socket, DatagramSocket()
class. Any ideas on how to get this information or any other
general tips about the problem - greatly appreciated.

Ned
 
R

Rob Shepherd

Janko said:
I am trying to write an application that simulates a router.
The problem I have is, that at some point during the execution
I need to know how much free space is there on a socket's buffer.
The socket is, Java's standard UDP socket, DatagramSocket()
class. Any ideas on how to get this information or any other
general tips about the problem - greatly appreciated.

Ned

This is a topic I am intersested in also.

The only options i'm aware of are set and get buffer size.
The set is just a hint and the OS/Native stuff will resize as it sees fit so a getsize
always follows a setsize to see what it has actually done.

I'm also trying network simulation with UDP.
But to make the system more predicatable, i'm wrapping/padding all transmissions in a sort
of PDU, in my case every packet is 450 bytes. I have a 2 byte header which is just a
length indicator, following this is my payload 1-448 bytes, the remainder is padded with junk.

This turns the system into an ATM style fixed size affair, but it means I can roughly
predict how many times I need to call socket.receive() (with a suitably small SO_Timeout)
every time my thread visits that end of the loop.
ergo there will be no more than X packets waiting for me. Any that arrive when the buffer
is full are dumped due to lack of space...

However trying to put this in to something reliable is proving to be a nightmare.
the resize() does wildly different things on x86 win32, x86 Linux and Sparc Solaris9.
Also for sending to localhost the buffer space appears differently, due to not going all
the way down to the bottom of the stack and backup,
Also the network card on my sun Blade seems to have a massive buffer of it's own, talk
about platform independance...sheesh....

This may be of little value to you, however our projects may be on similar veins so i
thought i'd share my experiences and see if anyone else has done anything like this??

anyone, anyone, Bueller?

regards

Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top