A Deep Dive into Two-Way Active Measurement Protocol (TWAMP)

The Two-Way Active Measurement Protocol (TWAMP), standardized in RFC 5357, provides a robust method for measuring network performance between two devices in an IP network. Unlike passive monitoring techniques that analyze existing traffic, TWAMP actively generates synthetic test packets to evaluate network characteristics. This offers a clear view of round-trip performance metrics. This active approach allows for the meticulous assessment of parameters such as delay, jitter, and packet loss, which are fundamental indicators of network health and user experience. The protocol’s design for bidirectional measurements offers advantages. Round-trip metrics do not necessitate complex clock synchronization between the source and destination devices, and the remote end can function with a simple echo mechanism.

Understanding TWAMP Architecture

TWAMP’s architecture is defined by four logical roles and two distinct protocols, which work in concert to facilitate accurate performance measurements.

The four logical entities are:

  • Control-Client: This entity initiates, starts, and stops test sessions. It is responsible for negotiating the parameters of the measurement with the Server.
  • Server: The Server listens for control messages from the Control-Client on a well-known TCP port (port 862). It manages one or more test sessions and responds to the Control-Client’s requests.
  • Session-Sender: Once a test session is established, the Session-Sender, often co-located with the Control-Client, generates and transmits the UDP-based test packets to the Session-Reflector.
  • Session-Reflector: This entity, typically co-located with the Server, receives test packets from the Session-Sender. It timestamps these packets and reflects them back to the Session-Sender. Crucially, the Session-Reflector does not typically store test results or packet information; that responsibility lies with the Session-Sender/Control-Client.
TWAMP architecture

Source: https://infocenter.nokia.com/public/7705SAR234R1A/index.jsp?topic=%2Fcom.nokia.oam-guide%2Ftwo-way_active_-ai9o99jjue.html

These roles are orchestrated through two main protocols 1:

  • TWAMP-Control: The Control-Client and the Server use this TCP-based protocol to establish, configure, start, and stop test sessions. The control connection ensures reliable setup and management of the measurement process. For instance, the Control-Client initiates a TCP connection, and after establishment, the Server sends a ‘Server Greetings’ message. The handshake continues with a ‘Setup Response’ from the client and a ‘Server Start’ message from the server. Afterwards, test sessions can be requested and accepted.
  • TWAMP-Test: The Session-Sender and the Session-Reflector use this UDP-based protocol to exchange the actual test packets used for performance measurement. The preference for UDP is due to its low overhead, reflecting the characteristics of many real-time applications whose performance TWAMP aims to measure.

A common and practical implementation involves a two-host architecture. In this setup, one physical device (the “client” or “controller”) hosts both the Control-Client and Session-Sender roles. Another device (the “server” or “responder”) combines the Server and Session-Reflector roles. This configuration simplifies deployment while maintaining the logical separation of control and test functions. The inherent separation of the control and test planes within TWAMP is a significant design choice. It enhances security by managing session initiation and control over a reliable TCP connection while actual test traffic, uses UDP. Therefore, this separation also provides flexibility in the collection and management of network performance data.

Key Use Cases of TWAMP

TWAMP’s precision and standardized nature make it invaluable for a variety of network management and assurance tasks. Its ability to provide detailed metrics on packet loss, delay, and jitter supports critical operational needs.

Key applications include:

  • Service Level Agreement (SLA) Compliance: TWAMP is frequently employed to verify that network performance meets the criteria defined in SLAs. For service providers, this is essential for demonstrating adherence to contractual obligations and for customers to ensure they receive the agreed-upon quality of service.
  • Network Performance Monitoring and Troubleshooting: Continuous TWAMP measurements can provide early warnings of network degradation, allowing operators to proactively address issues before they impact users. When problems do arise, TWAMP data helps pinpoint the location and nature of the performance bottlenecks, whether they are related to latency, packet loss, or jitter.
  • Quality of Service (QoS) Validation: Network administrators can use TWAMP to ensure that QoS mechanisms are functioning correctly. By setting specific Differentiated Services Code Point (DSCP) values in test packets, operators can verify that the network prioritizes traffic according to configured policies. If the DSCP value in the reflected packet differs from the sent value, it can indicate misconfigurations in QoS mappings, for example, between IP DSCP and MPLS EXP bits or VLAN priority bits.
  • Network Activation and Testing: Before new network services or segments go live, TWAMP can perform baseline performance tests to ensure they meet design specifications.6

The breadth of these use cases underscores TWAMP’s role not just as a measurement tool, instead as a cornerstone of comprehensive network assurance. The ability to deploy reflectors within existing network elements, like routers and base stations, means that it’s possible to achieve extensive network coverage with relatively few centralized probes. Which makes it a cost-effective solution for end-to-end visibility.

TWAMP in Action: twampy Implementation Example

The availability of open-source implementations like twampy significantly lowers the barrier to entry for utilizing and understanding TWAMP. twampy is a Python-based tool that implements both the full TWAMP protocol and the stateless TWAMP Light variant as defined in RFC 5357.

Here are simplified examples of how twampy might be used for TWAMP Light, which is a stateless version where test parameters are often predefined. The server reflects packets without maintaining extensive session state.

Simplified Receiver (Responder/Reflector) Example:

To set up a TWAMP Light reflector using twampy on a server machine, the command would be straightforward:

# Example: Starting a TWAMP Light responder listening
./twampy.py responder

This command starts twampy in responder mode (Session-Reflector). It will listen for incoming TWAMP test packets. Upon receiving a test packet, it will timestamp and reflect it back to the sender. This demonstrates the server/reflector side, completing the basic picture of a TWAMP Light exchange.

Simplified Sender Example:

To send TWAMP test packets from a client machine, you can use a command similar to the following:

# Example: Sending 50 TWAMP Light test packets, with a 200ms interval,
# to reflector at 172.31.0.42:862
$> python3 ./twampy.py sender  -c 10 -i 200 --tos 46 172.31.0.42
==================================================================
Direction         Min         Max         Avg          Jitter     Loss
-----------------------------------------------------------------------------
  Outbound:           0us         0us         0us         0us      0.0%
  Inbound:         2.81ms      3.36ms      3.06ms       114us      0.0%
  Roundtrip:        735us      1.99ms      1.21ms       216us      0.0%
-----------------------------------------------------------------------------
                                                    Jitter Algorithm [RFC1889]
 ==================================================================

This command instructs twampy to act as a Session-Sender. It will send 50 test packets (-c 50) at an interval of 200 milliseconds (-i 200) to the TWAMP Session-Reflector located at IP address 172.31.0.42 on port 862 (the well-known port for TWAMP control, though test ports can vary). This illustrates the client side of a TWAMP Light interaction, initiating the active measurement.

TWAMP Light

It is important to note that these examples showcase the simpler TWAMP Light (unauthenticated) mode. Full TWAMP involves a more complex TWAMP-Control session setup using TCP to negotiate test parameters before any TWAMP-Test UDP packets are exchanged. twampy also supports these full TWAMP controller and control client functionalities through separate subcommands (controller, controlclient).

The command-line options available in tools like twampy (e.g., –tos, –dscp, –padding, –do-not-fragment as seen in its help output) are particularly revealing. These options allow users to craft test traffic that closely mimics specific applications or service classes. For instance, setting a particular DSCP value allows for testing QoS policies. Adjusting padding can help assess performance with different packet sizes, relevant for MTU considerations or simulating various application payloads. This granularity means TWAMP is not just sending generic test packets; it enables the simulation of real-world traffic conditions, leading to more relevant and actionable performance measurements. This capability is crucial for validating intricate QoS policies and understanding how different types of network traffic will truly perform.

The Value of TWAMP

The Two-Way Active Measurement Protocol has established itself as an indispensable tool for understanding and managing IP network performance.

Its key advantages:

  • accuracy through precise timestamping and accounting for processing delays
  • standardization fostering multi-vendor interoperability
  • provision of comprehensive metrics including delay, jitter, and packet loss

Clearly set it apart from simpler diagnostic tools like ICMP Ping. 

The drawback of TWAMP is that you can’t expect almost any host to support it. In the contrary, ICMP is almost universally supported and much better known as a latency measurement utility.

decoration image

Get your free trial now

Monitor your network from the user perspective

You can share

Twitter Linkedin Facebook

Let's keep in touch

decoration image