You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Greg Dhuse (JIRA)" <ji...@apache.org> on 2008/03/28 20:38:24 UTC
[jira] Created: (DIRMINA-561) Socket.setReceiveBufferSize() called
after bind preventing correct TCP receive window scaling
Socket.setReceiveBufferSize() called after bind preventing correct TCP receive window scaling
---------------------------------------------------------------------------------------------
Key: DIRMINA-561
URL: https://issues.apache.org/jira/browse/DIRMINA-561
Project: MINA
Issue Type: Bug
Components: Transport
Affects Versions: 1.1.6, 1.1.5, 1.1.4, 1.1.3, 1.1.2, 1.1.1, 1.1.0, 1.1.7
Environment: Head of the 1.1 branch
Reporter: Greg Dhuse
Socket.setReceiveBufferSize() must be called before bind() on a ServerSocket in order to allow TCP receive window scaling up to the configured buffer size (http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html#setReceiveBufferSize(int)). Currently, socket options are set after bind() is called. This results in the correct Java receive buffer size, but does not allow the TCP stack to scale receive windows above 64k. Severe performance degradation can occur on high-latency high-bandwidth connections.
The following patch is a possible solution to this issue, though there may be a cleaner way to implement a fix within the framework.
Best regards,
Greg
Index: core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java
===================================================================
--- core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java (revision 642333)
+++ core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java (working copy)
@@ -163,6 +163,16 @@
try {
ch = SocketChannel.open();
ch.socket().setReuseAddress(true);
+
+ // Receive buffer size must be set BEFORE the socket is connected
+ // in order for the TCP window to be sized accordingly
+ if (config instanceof SocketConnectorConfig) {
+ SocketSessionConfig sessionConfig =
+ ((SocketConnectorConfig) config).getSessionConfig();
+ ch.socket().setReceiveBufferSize(
+ sessionConfig.getReceiveBufferSize());
+ }
+
if (localAddress != null) {
ch.socket().bind(localAddress);
}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (DIRMINA-561) Socket.setReceiveBufferSize() called
after bind preventing correct TCP receive window scaling
Posted by "Trustin Lee (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DIRMINA-561?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Trustin Lee resolved DIRMINA-561.
---------------------------------
Resolution: Fixed
Forgot to mark this issue as resolved.
> Socket.setReceiveBufferSize() called after bind preventing correct TCP receive window scaling
> ---------------------------------------------------------------------------------------------
>
> Key: DIRMINA-561
> URL: https://issues.apache.org/jira/browse/DIRMINA-561
> Project: MINA
> Issue Type: Bug
> Components: Transport
> Affects Versions: 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.1.0, 1.0.4, 1.1.1, 1.0.5, 1.1.2, 1.0.6, 1.1.3, 1.0.7, 1.1.4, 1.0.8, 1.1.5, 1.0.9, 1.1.6, 2.0.0-M1
> Environment: Head of the 1.1 branch
> Reporter: Greg Dhuse
> Assignee: Trustin Lee
> Fix For: 1.0.10, 1.1.7, 2.0.0-M2
>
> Original Estimate: 0h
> Remaining Estimate: 0h
>
> Socket.setReceiveBufferSize() must be called before bind() on a ServerSocket in order to allow TCP receive window scaling up to the configured buffer size (http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html#setReceiveBufferSize(int)). Currently, socket options are set after bind() is called. This results in the correct Java receive buffer size, but does not allow the TCP stack to scale receive windows above 64k. Severe performance degradation can occur on high-latency high-bandwidth connections.
> The following patch is a possible solution to this issue, though there may be a cleaner way to implement a fix within the framework.
> Best regards,
> Greg
> Index: core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java
> ===================================================================
> --- core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java (revision 642333)
> +++ core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java (working copy)
> @@ -163,6 +163,16 @@
> try {
> ch = SocketChannel.open();
> ch.socket().setReuseAddress(true);
> +
> + // Receive buffer size must be set BEFORE the socket is connected
> + // in order for the TCP window to be sized accordingly
> + if (config instanceof SocketConnectorConfig) {
> + SocketSessionConfig sessionConfig =
> + ((SocketConnectorConfig) config).getSessionConfig();
> + ch.socket().setReceiveBufferSize(
> + sessionConfig.getReceiveBufferSize());
> + }
> +
> if (localAddress != null) {
> ch.socket().bind(localAddress);
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Closed: (DIRMINA-561) Socket.setReceiveBufferSize() called
after bind preventing correct TCP receive window scaling
Posted by "Julien Vermillard (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DIRMINA-561?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Julien Vermillard closed DIRMINA-561.
-------------------------------------
> Socket.setReceiveBufferSize() called after bind preventing correct TCP receive window scaling
> ---------------------------------------------------------------------------------------------
>
> Key: DIRMINA-561
> URL: https://issues.apache.org/jira/browse/DIRMINA-561
> Project: MINA
> Issue Type: Bug
> Components: Transport
> Affects Versions: 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.1.0, 1.0.4, 1.1.1, 1.0.5, 1.1.2, 1.0.6, 1.1.3, 1.0.7, 1.1.4, 1.0.8, 1.1.5, 1.0.9, 1.1.6, 2.0.0-M1
> Environment: Head of the 1.1 branch
> Reporter: Greg Dhuse
> Assignee: Trustin Lee
> Fix For: 1.0.10, 1.1.7, 2.0.0-M2
>
> Original Estimate: 0h
> Remaining Estimate: 0h
>
> Socket.setReceiveBufferSize() must be called before bind() on a ServerSocket in order to allow TCP receive window scaling up to the configured buffer size (http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html#setReceiveBufferSize(int)). Currently, socket options are set after bind() is called. This results in the correct Java receive buffer size, but does not allow the TCP stack to scale receive windows above 64k. Severe performance degradation can occur on high-latency high-bandwidth connections.
> The following patch is a possible solution to this issue, though there may be a cleaner way to implement a fix within the framework.
> Best regards,
> Greg
> Index: core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java
> ===================================================================
> --- core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java (revision 642333)
> +++ core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java (working copy)
> @@ -163,6 +163,16 @@
> try {
> ch = SocketChannel.open();
> ch.socket().setReuseAddress(true);
> +
> + // Receive buffer size must be set BEFORE the socket is connected
> + // in order for the TCP window to be sized accordingly
> + if (config instanceof SocketConnectorConfig) {
> + SocketSessionConfig sessionConfig =
> + ((SocketConnectorConfig) config).getSessionConfig();
> + ch.socket().setReceiveBufferSize(
> + sessionConfig.getReceiveBufferSize());
> + }
> +
> if (localAddress != null) {
> ch.socket().bind(localAddress);
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (DIRMINA-561) Socket.setReceiveBufferSize() called
after bind preventing correct TCP receive window scaling
Posted by "Trustin Lee (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DIRMINA-561?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Trustin Lee updated DIRMINA-561:
--------------------------------
Affects Version/s: (was: 1.1.7)
1.0.0
1.0.1
1.0.2
1.0.3
1.0.4
1.0.5
1.0.6
1.0.7
1.0.8
1.0.9
2.0.0-M1
Fix Version/s: 2.0.0-M2
1.1.7
1.0.10
Assignee: Trustin Lee
I applied your patch after small modification. setReceiveBufferSize() is called before bind() only when the requested receiveBufferSize is bigger than 65535. 2.0.0-M1 had the same problem, so the similar patch has been applied, too.
> Socket.setReceiveBufferSize() called after bind preventing correct TCP receive window scaling
> ---------------------------------------------------------------------------------------------
>
> Key: DIRMINA-561
> URL: https://issues.apache.org/jira/browse/DIRMINA-561
> Project: MINA
> Issue Type: Bug
> Components: Transport
> Affects Versions: 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.1.0, 1.0.4, 1.1.1, 1.0.5, 1.1.2, 1.0.6, 1.1.3, 1.0.7, 1.1.4, 1.0.8, 1.1.5, 1.0.9, 1.1.6, 2.0.0-M1
> Environment: Head of the 1.1 branch
> Reporter: Greg Dhuse
> Assignee: Trustin Lee
> Fix For: 1.0.10, 1.1.7, 2.0.0-M2
>
> Original Estimate: 0h
> Remaining Estimate: 0h
>
> Socket.setReceiveBufferSize() must be called before bind() on a ServerSocket in order to allow TCP receive window scaling up to the configured buffer size (http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html#setReceiveBufferSize(int)). Currently, socket options are set after bind() is called. This results in the correct Java receive buffer size, but does not allow the TCP stack to scale receive windows above 64k. Severe performance degradation can occur on high-latency high-bandwidth connections.
> The following patch is a possible solution to this issue, though there may be a cleaner way to implement a fix within the framework.
> Best regards,
> Greg
> Index: core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java
> ===================================================================
> --- core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java (revision 642333)
> +++ core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java (working copy)
> @@ -163,6 +163,16 @@
> try {
> ch = SocketChannel.open();
> ch.socket().setReuseAddress(true);
> +
> + // Receive buffer size must be set BEFORE the socket is connected
> + // in order for the TCP window to be sized accordingly
> + if (config instanceof SocketConnectorConfig) {
> + SocketSessionConfig sessionConfig =
> + ((SocketConnectorConfig) config).getSessionConfig();
> + ch.socket().setReceiveBufferSize(
> + sessionConfig.getReceiveBufferSize());
> + }
> +
> if (localAddress != null) {
> ch.socket().bind(localAddress);
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.