BWC::measure

Description

This command allows you to start or stop measurement on a per policy or on a per flow basis after a flow has been assigned a policy. Once the measurement is started the measured bandwidth can be read by the user using ‘BWC::measure get ..’ iRules. Optionally users can direct the bandwidth measurement results to a ‘log publisher’ configured on the BIGIP system. Based on the log_publisher setting the measurement results will be logged to the log server indicated in the ‘log_publisher’. It is usually an external high speed log server. Configuring a log publisher is recommended setting even though it is optional.
create net bwc-policy gold_user max-rate 10mbps max-user-rate 10mbps measure enabled log-publisher "/Common/my_log_publisher" log-period 2048 dynamic enabled

In the above example we have set following measurement related attributes of a bwc policy.
measure enabled - This setting enables measurement on all sessions that belong to this bwc policy. Please note the “BWC::measure ..” iRule explained below takes precedence. That means when when this setting is disabled measurement for indivisul sessions can be enabled using the iRule below. This tmsh setting should only be used when one wants to enable measurement on all sessions of a policy

Syntax

BWC::measure <<<start|stop> | <identifier id_str> | <get rate|bytes>> <flow|session> [session_str]>

Examples

Example to start measurement on a session. Here the measurement will be started on the session $mycookie. Please note that enabling a bwc policy is a pre-requisite to functioning of measurement. Failing to do so will make this iRule failing indicating an error that bwc policy was not found.

when CLIENT_ACCEPTED {
  set mycookie [IP::remote_addr]:[TCP::remote_port]
  BWC::policy attach gold_user $mycookie
  BWC::measure start session $mycookie
}

Example to start measurement on a flow In this example measurement will start on the flow of running iRule’s context. Please note here also the enabling bwc policy on teh session that holds the flow is a pr-requisite to the functioning of measurement.
when CLIENT_ACCEPTED {
  set mycookie [IP::remote_addr]:[TCP::remote_port]
  BWC::policy attach gold_user $mycookie
  BWC::measure start flow
}

To start the bandwidth measurement for a flow inside a BWC policy and tag the results. This will start the measurement of bandwidth on the current flow or the flow over which the current iRule is running. The results will be published to the destination specified in the log_publisher setting for the gold_user bwc policy. The measurement results will be logged every ‘log_period’ amount of time, which is also specified in the policy settings for gold_user. Every log message containing the bandwidth result will carry the tag ‘MYFLOW’. This helps identify different types of bandwidth results when analyzing the bandwidth measurement results.
when CLIENT_ACCEPTED {
  set mycookie [IP::remote_addr]:[TCP::remote_port]
  BWC::policy attach gold_user $mycookie
  BWC::measure identifier MYFLOW flow
  BWC::measure start flow
}

To start the bandwidth measurement for a BWC session and get the periodic results. This example creates an instance of BWC policy gold_user and enables measurement on it upon the iRule event CLIENT_ACCEPTED. It also starts collecting so that it keeps getting notifed upon the data arrival. For every 1000 packets a measurement of bandwidth is logged. This is an example that illustrates how to measure bandwidth periodically using iRules. Note that the bandwidth measurement results are still sent to configured log_publisher at every log_period interval.
when CLIENT_ACCEPTED {
  set mycookie [IP::remote_addr]:[TCP::remote_port]
  set measureID "MYSESSION"
  BWC::policy attach gold_user $mycookie
  BWC::measure identifier $measureID session
  BWC::measure start session
}
when SERVER_CONNECTED {
  TCP::collect
  set count 0
}
when SERVER_DATA {
  if {$count >= 1000 } {
    set rate [BWC::measure get rate session]
    set bytes [BWC::measure get bytes session]
    log local0. "Rate $rate/sec : Bytes $bytes : for address $mycookie"
    set count 0
  }
  TCP::release
  TCP::collect
  incr count
}

An example log message that is sent to a log publisher.
Apr 2 16:29:04 MYSESSION BWC Measurement: Moving average - 539277 bytes/sec. Total bytes - 7305051