ICE4J 数据报包太小
ICE4J DatagramPacket too small
常规 DatagramSocket 工作正常...ICE4J DatagramSocket 似乎可以运行分类数据!?
发送包大小为2,500,但接收端始终为1500(使用常规Java DatagramSocket,接收包大小与发送大小相同)。
接收端:
Component rtpComponent = stream.getComponent(org.ice4j.ice.Component.RTCP);
CandidatePair rtpPair = rtpComponent.getSelectedPair();
videoDS = rtpPair.getDatagramSocket();
在话题中:
byte[] buffer = new byte[250000000];
final DatagramPacket dp = new DatagramPacket(buffer, buffer.length);
videoDS.receive(dp);
final byte[] clone = new byte[dp.getLength()];
System.arraycopy(dp.getData(), dp.getOffset(), clone, 0, dp.getLength());
final Image image = new Image(new ByteArrayInputStream(clone));
发送方几乎相同,只是 运行 在 Android...
唯一非工作代码的区别是第一段用于发送和接收。如果我使用常规 Java 套接字,它将工作(但当然不能在路由器后面,这就是我使用 Ice4J 的原因)。
The sending size packet is 25,000 but the receiving end is always 1500
您永远不会接收大于路径 MTU 的 UDP 数据报,除非:
- 你和目标之间没有路由器,and/or
- 数据报没有分片,或者
- 碎片全部到达目标
否则任何片段的丢失都会导致整个数据报的丢失。
普遍接受的 UDP 数据报负载限制是 534 字节。不是 25k.
我找到了主要问题....
参见组织ice4j.stack.Connector 第 160 行
/*
* Make sure localSock's receiveBufferSize is taken into
* account including after it gets changed.
*/
int receiveBufferSize = 1500;
数据显然被截断了....请参阅第 188 行
packet.setData(
new byte[receiveBufferSize],
0,
receiveBufferSize);
....
localSock.receive(packet); //line 200
我当前的解决方案是将 receiveBufferSize 编辑为 25000,实际的数据包数据量是正确的。也许我会要求合并。
常规 DatagramSocket 工作正常...ICE4J DatagramSocket 似乎可以运行分类数据!?
发送包大小为2,500,但接收端始终为1500(使用常规Java DatagramSocket,接收包大小与发送大小相同)。
接收端:
Component rtpComponent = stream.getComponent(org.ice4j.ice.Component.RTCP);
CandidatePair rtpPair = rtpComponent.getSelectedPair();
videoDS = rtpPair.getDatagramSocket();
在话题中:
byte[] buffer = new byte[250000000];
final DatagramPacket dp = new DatagramPacket(buffer, buffer.length);
videoDS.receive(dp);
final byte[] clone = new byte[dp.getLength()];
System.arraycopy(dp.getData(), dp.getOffset(), clone, 0, dp.getLength());
final Image image = new Image(new ByteArrayInputStream(clone));
发送方几乎相同,只是 运行 在 Android...
唯一非工作代码的区别是第一段用于发送和接收。如果我使用常规 Java 套接字,它将工作(但当然不能在路由器后面,这就是我使用 Ice4J 的原因)。
The sending size packet is 25,000 but the receiving end is always 1500
您永远不会接收大于路径 MTU 的 UDP 数据报,除非:
- 你和目标之间没有路由器,and/or
- 数据报没有分片,或者
- 碎片全部到达目标
否则任何片段的丢失都会导致整个数据报的丢失。
普遍接受的 UDP 数据报负载限制是 534 字节。不是 25k.
我找到了主要问题....
参见组织ice4j.stack.Connector 第 160 行
/*
* Make sure localSock's receiveBufferSize is taken into
* account including after it gets changed.
*/
int receiveBufferSize = 1500;
数据显然被截断了....请参阅第 188 行
packet.setData(
new byte[receiveBufferSize],
0,
receiveBufferSize);
....
localSock.receive(packet); //line 200
我当前的解决方案是将 receiveBufferSize 编辑为 25000,实际的数据包数据量是正确的。也许我会要求合并。