Traffic Policy

Plain HTML / Printer friendly.Plain HTML / Printer friendly.

A dedicated advanced tool to flexibly control traffic.

By default a blank policy is given, with location multipliers set to 1.


Below is a table of variables that can be used in maintaining the policy.

VariableDescriptionExample values
client_ip
Client IP
"1.2.3.4"
client_asnClient IP AS (Autonomous System) Number which is derived from the client_ip above. It can be looked up via a WHOIS tool.5312
client_countryClient country in 2-letter ISO 3166 notation derived from the client_ip.

"MY"

publisher_idThe publisher's ID derived from the site_id below.7234213
site_idResource or CDN site's ID.7234213
site_typeCDN site or resource type derived from site_id aboveHTTP, RTMP_VOD
timeCurrent time in UTC format as HHMM integer.

423 as 4:23 AM

1847 for 6:47 PM

peered_forNone if it is direct traffic, or operator's ID of buyer if peered. It is derived from the site_id

None

5732 (operator id 5732)


List of keywords, functions and operators

Keyword / Function / OperatorDefinition
update_location_weight(multiplier[, location=None[, country=None[, continent=None]]])

Updates the weight of a location.

Do note that if you have set this number to zero, due to a dampening factor of 1 billion, there is still a remote probability that a request still goes to that location. So a zero setting is not entirely and truly zero.

Accepts either “location” (id), “country”, or “continent” to select locations.

The allowed continent codes are AS,AF,EU,NA,OC,SA for Asia, Africa, Europe, North America, Oceania, South America respectively.

Conditional if, elif, elseWorks like a standard if else conditional statement in any programming language.
#Comment any unnecessary item.
Comparison operator (==, >, <, not, in)Works like a standard comparison operator in any third generation programming language.
List constructor []Allows comparison with lists e.g. if client_asn in [ 1, 2, 3 ].
String constructor "" (double quotes) or '' (single quote)Place any string inside.
Numeric constructor 
Boolean operators (and, or, not) 

 


Example scripts

Serve TMNet visitors from Location 432 only

if client_asn == 4788:
update_location_weight(infinity, location=432)

Serve Malaysian visitors from Malaysian servers only

if client_country == “MY”:
update_location_weight(infinity, country=”MY”)

Do not serve Thai or Vietnamese visitors from China and Japan locations

if client_country == “TH” or client_country == “VN”:
update_location_weight(0, country=”CN”)
update_location_weight(0, country=”JP”)

Do not serve peered traffic from Location 5234

if peered_for is not None:
update_location_weight(0, location=5324)

Deprioritize Location 483 from 0300 to 0900 hours

if 300 < time < 900:
update_location_weight(0.5, location=483)

Never serve Publisher 98743 from NA continent

if publisher_id == 98743:
update_location_weight(0, continent=”NA”)

Serve SG Visitors From SG Edge Server Only While Disallow SG Edge Server To Serve Other Countries

if client_country == "SG":
  update_location_weight(infinity, country="SG")
else:
  update_location_weight(0, country="SG")