The lower-layer Tcl API provides an object-oriented Tcl interface to the ByteBlower client API. By interacting with the various API objects, a Tcl script controls the ByteBlower server in a direct way.
All server functionality is made available to the user through the client API. Each API call corresponds with a single action on the server, such as setting the MAC address of a network host, starting a traffic stream or performing DHCP.
On the other hand, the API is the only way to configure the server. This means many higher-level concepts such as a traffic flow or a latency measurement do not exist in the API, because they do not exist on the server.
For example, setting up a typical latency measuring scenario involves:
Note that the mapping of concepts such as flow and latency measurement to the steps described above is exactly what happens in the higher-layer API. That API maps declarative scenario configurations to sequences of API calls. Such a mapping also occurs in back-end of the ByteBlower GUI when the users runs a scenario!
The object-oriented Tcl API is built on TOOP (Tcl object-oriented programming). TOOP is a Tcl library that enhances the Tcl language with object-oriented facilities and is developed in-house at Excentis.
Using the TOOP facilities, a script can interact with Tcl API objects as follows:
For example, the statement above will execute Method.Name
on the object referenced by the variable object
. The arguments and the return value may either be API objects of their own or regular Tcl string or list values.
The ByteBlower Tcl API becomes available in a Tcl shell by loading the following package:
The complete API is constructed in a hierarchical way with the ByteBlower object at the top. The ByteBlower object is a singleton and acts as an entry point to the API. To retrieve the object, call the following (static) method of the ByteBlower class:
The ByteBlower object can contain one or more ByteBlowerServer objects. By calling ByteBlower::Server.Add, the client connects to the specified server. A server API object is created and returned:
The server API object in turn allows the script to create a (theoretically) infinite amount of ByteBlowerPort objects. Such ByteBlower ports represent network hosts and are the cornerstone of the API.
Such a port is created by calling ByteBlowerServer::Port.Create. The physical interface on which the port must be created is passed as an argument to the method:
In this example, a network host is created on the 48th physical interface of the ByteBlower switch connected to the 2nd trunking interface. This physical location determines where the host will be created within the network under test.
By configuring these ByteBlower ports they can participate in the system under test. Check out the documented examples or the API reference to see what kind of actions can be performed on ByteBlowerPort objects. This functionality mainly consist of:
The ByteBlower Tcl API is completely synchronous: each API call immediately affects the server state and only returns once it is finished. If an error occurs at either the client or server software, this is immediatly reported back in the form of an exception.
Having a synchronous API means that the server cannot notify the script of events, such as a tcp flow that has finished. Therefore scripts may need to check the server state periodically, to see if some condition (e.g. tcp connection status value is 'finished') is already met.
Such concepts and techniques are explained in the examples page of this documentation. The example scripts that are packaged with the ByteBlower software show them in action as well!