SolarCapture C Bindings User Guide  SF-115721-CD
Draft 2A
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
sc_ts_adjust Node Reference

Adjust packet buffer timestamps

Detailed Description

This node adjusts the timestamps on the packet buffers passing through. Timestamps can be adjusted by a constant offset, and inter-packet gaps can also be scaled, or set to a fixed packet rate or bandwidth.

This node is often used together with sc_pacer to emit packets in real-time (or speeded up or slowed down). The sc_ts_adjust node is used to modify the timestamps in the input so that they give the desired transmit time, and sc_pacer holds buffers up until their transmit time is reached.

Here is an example using the Python bindings that reads packets from a PCAP file, and transmits them through interface eth4. The packets are transmitted at a rate of 1000 packets per second, and transmitting starts 5 seconds after the process begins:

reader = thread.new_node('sc_reader', args=dict(filename="pkts.pcap", prefill="all-input"))
ts_adjust = thread.new_node('sc_ts_adjust', args=dict(start_now=1, offset=5, pps=1000))
pacer = thread.new_node('sc_pacer')
injector = thread.new_node('sc_injector', args=dict(interface="eth4"))
reader.connect(ts_adjust).connect(pacer).connect(injector)

Arguments

Argument Optional? Default Type Description
start_now Yes 0 SC_PARAM_INT Make the first packet timestamp be "now"
start_at Yes 0.0 SC_PARAM_DBL Make the first packet timestamp be the one given by this argument (in seconds since 1970)
offset Yes 0.0 SC_PARAM_DBL Adjust timestamps by the given relative offset (seconds)
speedup Yes 1.0 SC_PARAM_DBL Adjust inter-packet gap to speed up or slow down by the given factor
pps Yes 0.0 SC_PARAM_DBL Adjust inter-packet gap to give fixed packet rate
fixed_rate Yes 0.0 SC_PARAM_DBL For backward compatibility only (same as pps)
bw Yes 0.0 SC_PARAM_DBL Adjust inter-packet gap to give fixed bandwidth

NB. The fixed bandwidth mode (bw) uses the actual payload length given by sc_packet_bytes() rather than the frame_len field.