Re: DatagramSocket setTrafficClass



On 16 abr, 19:04, haywood.Rich...@xxxxxxxxx wrote:
I was wondering if anyone could provide any details of which
environments anyone has got the setTrafficClass method of the
DatagramSocket class to make alterations to the DSCP field in the IP
header. I realise that the document says that support is optional,
but I am trying to find out in which environments it does actually
work.

I have written the code below and have ran it under windows xp and
vista and also under the latest version of knoppix - but in every
occasion when I use wireshark I get the result:

Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00)

The version of Java on vista is Java version Java(TM) SE Runtime
Environment (build 1.6.0_02-b06), unfortunatly I don't have the
version of Java on knoppix to hand.

Under knoppix I can use iperf and change the -S parameter to
successfully change the DSCP field in the packet, so I am guessing
that I should be able to do the same with Java but I have yet to
achieve this.

All help, suggestions are greatly received.

import java.net.*;
import java.io.*;

class UDP_TOS_TEST {
public static void main(String[] args){
new UDP_TOS_TEST();
}

public UDP_TOS_TEST(){
try{
DatagramSocket dgramSocket = new DatagramSocket();

int counter = 0;
byte[] out = new byte[1000];

DatagramPacket dgram = new DatagramPacket(out, 1000,
InetAddress.getByName("192.168.1.1"), 6000) ;
dgram.setData(out);

while(true){
counter = (counter+1)%256;
dgramSocket.setTrafficClass(counter);
dgramSocket.send(dgram);
}
} catch (Exception e){
e.printStackTrace();
}
}

}

java "your program" -D java.net.preferIPv4Stack=true
.



Relevant Pages

  • DatagramSocket setTrafficClass
    ... DatagramSocket class to make alterations to the DSCP field in the IP ... but I am trying to find out in which environments it does actually ... The version of Java on vista is Java version JavaSE Runtime ...
    (comp.lang.java.help)
  • Re: VS IDE Blues (or code bloat)
    ... notably Java and C++." ... I would hardly call that a ripoff. ... Greg ... I use both environments every day, ...
    (microsoft.public.dotnet.general)
  • Re: VS IDE Blues (or code bloat)
    ... "C# is a bitwise copy of Java" ... > critial apps in these environments. ... > I only have to charge the customer for hardware and labor. ...
    (microsoft.public.dotnet.general)
  • Re: vs for .Net SUCKS Big Time
    ... Thanks for the opinion and info. ... Then we can write programs for these environments using C++ and ... Java 6 has a much better runtime environment than prior ... a moron for putting up with it. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Is anything easier to do in java than in lisp?
    ... Is there any real difference between lisp ... debugging environments that allow introspection and Java debugging ... in java working with linked lists must be an awful pain. ...
    (comp.lang.java)