Problem with DatagramPacket and the IP ToS-Field

R

richard.kulzer

Hello!

I send UDP packets from A to B, both in the same LAN.
In the sending DatagramSocket i set the Traffic Class like this
sendingSocket.setTrafficClass(0x08|0x10).
sendingSocket.getTrafficClass() --> returns 24, ok.

But on the receivers side, also after receiving some packets,
receivingSocket.getTrafficClass() returns 0.
So i think, the IP Header, or at least the Type-of-Service-Field, is
overwritten anywhere. But where? And how can i avoid this?

thanks a lot
Richi
 
R

Roedy Green

But on the receivers side, also after receiving some packets,
receivingSocket.getTrafficClass() returns 0.

that is information for the transport net, not for the receiver,
right? It may not even be transmitted in the packet itself. Get a
book on UDP protocol to check.
--
Roedy Green Canadian Mind Products
http://mindprod.com

"Here is a point of no return after which warming becomes unstoppable
and we are probably going to sail right through it.
It is the point at which anthropogenic (human-caused) warming triggers
huge releases of carbon dioxide from warming oceans, or similar releases
of both carbon dioxide and methane from melting permafrost, or both.
Most climate scientists think that point lies not far beyond 2°C (4°F) C hotter."
~ Gwynne Dyer
 
M

Mark Space

Roedy said:
that is information for the transport net, not for the receiver,
right? It may not even be transmitted in the packet itself. Get a
book on UDP protocol to check.

There's no "Traffic Class" header in UPD. It has a source port, a
destination port, a length and a checksum. With IPv4, it has a source
IP, a destination IP, a protocol and another length field.

<http://en.wikipedia.org/wiki/User_Datagram_Protocol>

I didn't read through the various RFCs mentioned in setTrafficClass, but
it seems to me Roedy is right. That value is for performance tunning
your network stack, it never goes out on the wire.
 
R

richard.kulzer

thanks a lot guys!

I just wanted to set the ToS-Field of the IP Header in the UDP packet.
Reading on the receivers side was just for debugging. And of course, i
cannot read a packets ToS-Field via the Socket. I didn't find any
Method to read the ToS-Field of an incoming packet. But thats not the
matter, i can do this with wireshark. What i found out is:
Setting the ToS-Field on the senders side with socket.setTrafficClass
(0x02|0x08) works great. I sniffed the sent packets with wireshark on
the senders side. The ToS-Field was set! Alright.
Then i sniffed the packets on the receivers side, and... surprise, the
ToS-Field was set there too! Thats what i wanted to do.
Why does it work now and didn't work before??? Because i switched the
PC! So, the problem was the sending machine, it was not a Java
problem.
But why the other PC didn't set it... I don't know. However, the
problem is solved an i'm happy!

cheers!
 
O

Owen Jacobson

There's no "Traffic Class" header in UPD. It has a source port, a
destination port, a length and a checksum. With IPv4, it has a source
IP, a destination IP, a protocol and another length field.

<http://en.wikipedia.org/wiki/User_Datagram_Protocol>

I didn't read through the various RFCs mentioned in setTrafficClass,
but it seems to me Roedy is right. That value is for performance
tunning your network stack, it never goes out on the wire.

The IP header diagrammed in that article is a "simplified" version used
to calculate the checksum. The real IP header includes a bunch of
fields before the source address, including (bits 8-15) "Type of
Service". Reading the DatagramSocket docs suggests that
setTrafficClass/getTrafficClass do map to this field, but I'd need to
sit down with Wireshark and see to be sure.

<http://en.wikipedia.org/wiki/IPv4> tells all. :)

-o
 

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

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,105
Latest member
sheetaldubay7750ync
Top