sctpstate.d Tracing State Changes
            
         This following DTrace script demonstrates the capability to trace SCTP state changes:
#!/usr/sbin/dtrace -s
#pragma D option quiet
#pragma D option switchrate=10
int last[int];
dtrace:::BEGIN
{
        printf(" %3s %12s  %-20s    %-20s\n", "CPU", "DELTA(us)", "OLD", "NEW");
        last = timestamp;
}
sctp:::state-change
/ last[args[1]->cs_cid] /
{
        this->elapsed = (timestamp - last[args[1]->cs_cid]) / 1000;
        printf(" %3d %12d  %-20s -> %-20s\n", cpu, this->elapsed,
            sctp_state_string[args[5]->sctps_state], sctp_state_string[args[3]->sctps_state]);
        last[args[1]->cs_cid] = timestamp;
}
sctp:::state-change
/ last[args[1]->cs_cid] == 0 /
{
        printf(" %3d %12s  %-20s -> %-20s\n", cpu, "-",
            sctp_state_string[args[5]->sctps_state],
            sctp_state_string[args[3]->sctps_state]);
        last[args[1]->cs_cid] = timestamp;
}The fields printed are as follows:
| Field | Description | 
|---|---|
| 
 | CPU ID of the event | 
| 
 | Time since previous event for that connection, microseconds | 
| 
 | Old SCTP state | 
| 
 | New SCTP state |