开发者

Java Media Framework always generating multicast packets with TTL=1

开发者 https://www.devze.com 2022-12-24 06:38 出处:网络
I need to generate a G711 multicast audio stream, and came across the AVTransmit2 sample as part of the Java Media Framework.

I need to generate a G711 multicast audio stream, and came across the AVTransmit2 sample as part of the Java Media Framework.

Fundementally this works, however the multicast packets all have TTL set to 1.

I found some documentation that suggested the SessionAddress could specify a TTL value, so I've tried changing that i.e. destAddr = new SessionAddress( ipAddr, port, 255);

I also found some comments that the problems might be due to java defaulting to IPv6, so I've tried to force it to ipv4 by starting it like this: java -Djava.net.preferIPv4Stack=true -classpath "." AVTransmit2 javasound://8000 239.1.10.65 20480

H开发者_StackOverflow中文版owever looking in wireshark, the packets still have TTL=1

I'm using JMF2.1.1e

Any suggestions how to resolve this?


This is about six months late, but I found this thread while looking to solve the same problem, here's what I've found:

I also tried setting the ttl value when creating my SessionAddress objects, but using wireshark, the packets still only had ttl of 1. However, I was using different addresses for initialization and target, but the ttl setting worked when I used the same address. So if you have two SessionAddress objects, such as

String addr = "239.192.1.1";
int port = 22224;
int ttl = 32;

SessionAddress multiAddress =
    new SessionAddress(InetAddress.getByName(addr), port, ttl);
SessionAddress localAddress = 
    new SessionAddress(InetAddress.getLocalHost(), SessionAddress.ANY_PORT, ttl);
SessionAddress multiAny = 
    new SessionAddress(InetAddress.getByName(addr), port, ttl);

Then you have to use the addresses as follows:

GOOD

RTPManager rtpManager = RTPManager.newInstance();
rtpManager.initialize(multiAddress);
rtpManager.addTarget(multiAddress);

GOOD

RTPManager rtpManager = RTPManager.newInstance();
rtpManager.initialize(multiAny);
rtpManager.addTarget(multiAddress);

BAD

RTPManager rtpManager = RTPManager.newInstance();
rtpManager.initialize(localAddress);
rtpManager.addTarget(multiAddress);

EDIT: it seems only the SessionAddress passed to initialize() needs to have ttl set

0

精彩评论

暂无评论...
验证码 换一张
取 消