[JBoss JIRA] (JGRP-1880) UDP.ip_ttl is ignored and is always 1
by Bela Ban (JIRA)
[ https://issues.jboss.org/browse/JGRP-1880?page=com.atlassian.jira.plugin.... ]
Bela Ban commented on JGRP-1880:
--------------------------------
I could use reflection, but that's not nice:
{code:java}
DatagramSocket sock=new DatagramSocket(7500);
Method getImpl=sock.getClass().getDeclaredMethod("getImpl");
getImpl.setAccessible(true);
DatagramSocketImpl impl=(DatagramSocketImpl)getImpl.invoke(sock);
System.out.println("impl = " + impl);
Method setTimeToLive=impl.getClass().getDeclaredMethod("setTimeToLive", int.class);
Method getTimeToLive=impl.getClass().getDeclaredMethod("getTimeToLive");
getTimeToLive.setAccessible(true);
setTimeToLive.setAccessible(true);
int ttl=0;
ttl=(int)getTimeToLive.invoke(impl);
System.out.println("ttl = " + ttl);
ttl=5;
setTimeToLive.invoke(impl, ttl);
ttl=(int)getTimeToLive.invoke(impl);
System.out.println("ttl = " + ttl);
byte[] buf={'B', 'e', 'l', 'a'};
DatagramPacket packet=new DatagramPacket(buf, 0, buf.length, InetAddress.getByName("228.8.8.8"), 7500);
sock.send(packet);
{code}
> UDP.ip_ttl is ignored and is always 1
> -------------------------------------
>
> Key: JGRP-1880
> URL: https://issues.jboss.org/browse/JGRP-1880
> Project: JGroups
> Issue Type: Bug
> Reporter: Bela Ban
> Assignee: Bela Ban
> Fix For: 3.6
>
>
> Since we switched from using a {{MulticastSocket}} for sending of multicast packets to a {{DatagramSocket}}, the time-to-live (TTL) of a packet is always {{1}}. The reason is that method {{setTimeToLive()}} only exists in {{MulticastSocket}}, but not in {{DatagramSocket}}.
> We cannot revert the code and use a {{MulticastSocket}} to send multicasts, as this won't reveal the real IP address of the sender, but only the multicast address, and the real address is needed to drop packets at the _transport level_.
> Investigate whether we could use reflection to get the {{DatagramSocketImpl}} and call {{setTimeToLive()}}.
--
This message was sent by Atlassian JIRA
(v6.3.1#6329)
10 years
[JBoss JIRA] (JGRP-1880) UDP.ip_ttl is ignored and is always 1
by Bela Ban (JIRA)
[ https://issues.jboss.org/browse/JGRP-1880?page=com.atlassian.jira.plugin.... ]
Bela Ban edited comment on JGRP-1880 at 9/25/14 8:36 AM:
---------------------------------------------------------
I found out that the DatagramSocket returned via {{DatagramChannel.socket()}} has a stupid readLock / writeLock held when calling {{receive()}} or {{send()}} respectively. This means that the unicast receiver in TP will block until unicast messages are received, but this will also keep the _sender_ from sending any data !
Very stupid and breaking the semantics of {{DatagramSocket.send()}} which allows for concurrent receiving and sending as there's no readLock or writeLock, but synchronization is done on the DatagramPacket only.
I don't really want to use 2 separate unicast sockets now; one for receiving unicasts and one for sending unicasts. More investigation needed...
was (Author: belaban):
I found out that the DatagramSocket returned via {{DatagramChannel.socket()}} has a stupid readLock / writeLock held when calling {{receive()}} or {{send()}} respectively. This means that the unicast receiver in TP will block until unicast messages are received, but this will also keep the _sender_ from sending any data !
Very stupid and breaking the semantics of {{DatagramSocket.send()}} which allows for concurrent receiving and sending as there's no readLock or writeLock, but synchronization is done on the DatagramPacket only.
I don't really want to use 2 separate unicast sockets now; one for receiving unicasts and one for sending unicasts. More investigate needed...
> UDP.ip_ttl is ignored and is always 1
> -------------------------------------
>
> Key: JGRP-1880
> URL: https://issues.jboss.org/browse/JGRP-1880
> Project: JGroups
> Issue Type: Bug
> Reporter: Bela Ban
> Assignee: Bela Ban
> Fix For: 3.6
>
>
> Since we switched from using a {{MulticastSocket}} for sending of multicast packets to a {{DatagramSocket}}, the time-to-live (TTL) of a packet is always {{1}}. The reason is that method {{setTimeToLive()}} only exists in {{MulticastSocket}}, but not in {{DatagramSocket}}.
> We cannot revert the code and use a {{MulticastSocket}} to send multicasts, as this won't reveal the real IP address of the sender, but only the multicast address, and the real address is needed to drop packets at the _transport level_.
> Investigate whether we could use reflection to get the {{DatagramSocketImpl}} and call {{setTimeToLive()}}.
--
This message was sent by Atlassian JIRA
(v6.3.1#6329)
10 years
[JBoss JIRA] (JGRP-1880) UDP.ip_ttl is ignored and is always 1
by Bela Ban (JIRA)
[ https://issues.jboss.org/browse/JGRP-1880?page=com.atlassian.jira.plugin.... ]
Bela Ban commented on JGRP-1880:
--------------------------------
I found out that the DatagramSocket returned via {{DatagramChannel.socket()}} has a stupid readLock / writeLock held when calling {{receive()}} or {{send()}} respectively. This means that the unicast receiver in TP will block until unicast messages are received, but this will also keep the _sender_ from sending any data !
Very stupid and breaking the semantics of {{DatagramSocket.send()}} which allows for concurrent receiving and sending as there's no readLock or writeLock, but synchronization is done on the DatagramPacket only.
I don't really want to use 2 separate unicast sockets now; one for receiving unicasts and one for sending unicasts. More investigate needed...
> UDP.ip_ttl is ignored and is always 1
> -------------------------------------
>
> Key: JGRP-1880
> URL: https://issues.jboss.org/browse/JGRP-1880
> Project: JGroups
> Issue Type: Bug
> Reporter: Bela Ban
> Assignee: Bela Ban
> Fix For: 3.6
>
>
> Since we switched from using a {{MulticastSocket}} for sending of multicast packets to a {{DatagramSocket}}, the time-to-live (TTL) of a packet is always {{1}}. The reason is that method {{setTimeToLive()}} only exists in {{MulticastSocket}}, but not in {{DatagramSocket}}.
> We cannot revert the code and use a {{MulticastSocket}} to send multicasts, as this won't reveal the real IP address of the sender, but only the multicast address, and the real address is needed to drop packets at the _transport level_.
> Investigate whether we could use reflection to get the {{DatagramSocketImpl}} and call {{setTimeToLive()}}.
--
This message was sent by Atlassian JIRA
(v6.3.1#6329)
10 years