Forum Discussion
david_wang_2073
Jul 22, 2005Historic F5 Account
send a client message in a long tcp connection to multi-server at the same time
It was said that Bigip V9 is possible to break out client transactions and load-balances them to different servers using one connect as below:
NCPDP transaction rule
rule NCPDP_transaction {
when CLIENT_ACCEPTED {
set request_len 0
set request_hdr ""
set request_pending 0
set response_len 0
TCP::collect
}
when CLIENT_DATA {
set tlen [TCP::offset]
Haven't found the start of the transaction yet
if { $request_len == 0 } {
set trans [TCP::payload]
if { not ( $trans starts_with "\002" ) } {
This should really never happen
log local0. "Missing request STX - [IP::remote_addr]:[TCP::remote_port]"
set index [string first "\002" $trans]
if { $index == -1 } {
No STX found - drop everything we've collected so far.
TCP::payload replace 0 $tlen ""
TCP::collect
return
}
Drop any data up to the STX
TCP::payload replace 0 $index ""
set tlen [TCP::offset]
set trans [TCP::payload]
}
Wait until we've got a whole transaction header
if { $tlen < 25 } {
TCP::collect
return
}
scan [string range $trans 1 6] "%d" request_len
set request_hdr [string range $trans 7 24]
Need to account for STX/ETX characters in the total transaction length
incr request_len 2
}
Received all of the transaction
if { $tlen >= $request_len and not $request_pending } {
Release the current transaction
TCP::release $request_len
Hold any additional requests until we get the response
set request_pending 1
Reset current transaction
set request_len 0
}
Always keep collecting
TCP::collect
}
when LB_FAILED {
LB::reselect
}
when SERVER_CONNECTED {
TCP::collect
}
when SERVER_DATA {
set tlen [TCP::offset]
Haven't found the start of the transaction yet
if { $response_len == 0 } {
set trans [TCP::payload]
This should never happen
if { not ( $trans starts_with "\002" ) } {
log local0. "Missing response STX - [IP::remote_addr]:[TCP::remote_port]"
set index [string first "\002" $trans]
if { $index == -1 } {
No STX found - just drop everything we've collected so far.
TCP::payload replace 0 $tlen ""
TCP::collect
return
}
Drop any data up to the STX
TCP::payload replace 0 $index ""
set tlen [TCP::offset]
set trans [TCP::payload]
}
Wait until we've got the whole transaction header
if { $tlen < 25 } {
TCP::collect
return
}
scan [string range $trans 1 6] "%d" response_len
set response_hdr [string range $trans 7 24]
Need to account for STX/ETX characters in the total transaction length
incr response_len 2
}
Received all of the transaction response
if { $tlen >= $response_len } {
if { $request_pending } {
Release the current response and invoke a detach
TCP::release $response_len
set response_len 0
Trigger USER_RESPONSE on the clientside so we can detach, etc.
TCP::notify response
} else {
Received a response while there was no pending request - drop it
log local0. "Received unsolicited response from [IP::remote_addr]:[TCP::remote_port], len: $response_len, hdr: $response_hdr"
TCP::payload replace 0 $response_len ""
set response_len 0
}
}
Always keep collecting
TCP::collect
}
when USER_RESPONSE {
Detach the server so the next request can be re-load balanced
LB::detach
Is the clientside already holding another request?
if { $request_len == 0 } {
Release any future request
set request_pending 0
} elseif { [TCP::offset] >= $request_len } {
Release the current transaction
TCP::release $request_len
set request_len 0
}
}
}
Now I wonder whether it is possible for Bigip v9 to send a selected transaction request in one long alive tcp connection to multi-server at the same time. For example, there is a transaction request AAAAABBBBBAAAA sent from client side, it was hoped all the nodes can receive this request.
- drteeth_127330Historic F5 AccountUnfortunately, that's not yet possible. An iRule can make an LB decision, but there is no way to open multiple connections.
- GaryZ_31658Historic F5 AccountThis post is almost a year old...
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects