Forum Discussion

Roflcopter's avatar
Roflcopter
Icon for Nimbostratus rankNimbostratus
Aug 02, 2017

Message Base Load Balancing

We have a situation where we are looking to use MBLB to load balance a TCP connection.

The situation is that the client connects to the F5, creates a TCP connection, sends the first message within that TCP connection, the first back end server sends back a response. The client then sends a second message within the same TCP connection, the F5 sends it to the second back end server. The second back end server responds back to the F5 but the F5 never sends it back to the client.

I have confirmed the above via packet captures on the virtual server, and on the back end vlan interface on the F5.

I have used a combination of irules that I have found within DevCentral and from the logging I can confirm it is collecting the correct messages (also from the packet captures I can confirm this)

Below is the iRule we are using. We are looking at the first 2 bytes to determine how many bytes we need to capture for each message.

It is a combination from this page -https://devcentral.f5.com/wiki/iRules.TCP__notify.ashx and this page - https://devcentral.f5.com/questions/calculating-a-two-byte-header-in-message-payload

when CLIENT_ACCEPTED {
set message_length      0
set collected_length    0
set at_msg_start        1

TCP::collect
}

when CLIENT_DATA {
set data [TCP::payload]
set collected_length [TCP::payload length]
    if { $at_msg_start > 0} {

        if { $collected_length < 2 } {
            TCP::collect
            return
        }
        log local0. "Start of message, length = $message_length"
        binary scan [TCP::payload] S message_length
        log local0. "After binary scan $message_length"
        set tcppayload [TCP::payload]
        log local0. "TCP Payload = $tcppayload"
        set at_msg_start 0
    }
else {
    log local0. " ... collected = ($collected_length)"

}

    if { $collected_length >= $message_length } {
    log local0. " ... end of message, collected = ($collected_length)"
        set at_msg_start 1
        TCP::release $message_length
        TCP::notify request
        log local0. "...after purge, pay load length = ([TCP::payload length])"
        log local0. "...after purge, collected length = ($collected_length)"
    }

    TCP::collect
}
No RepliesBe the first to reply