A D Script for Observing the Network
A little gem included with the Crossbow Virtual Wire Demo Tool is a DTrace script and associated Chime display written by Crossbow engineer Kais Belgaied. I've augmented the script a bit by adding an END clause to format the output, which shows the number of bits transferred over the period of time the script is run:
bleonard@opensolaris:~$ dtrace -s vWireBuilder/VWire/so.d Tracing... Hit Ctrl-C to end. ^C Process Zone Protocol Destination Port Bits pidgin global TCP 202.43.216.31 5050 296 firefox-bin global TCP 66.196.87.126 443 13968 Trace ran for 29 seconds
The associated Chime display is useful when you want to monitor a system with lots of network traffic. In this example I'm using Netperf to simulate traffic between my global zone and a local zone, which has been configured to run at IP address 10.0.1.50:

In this example you can see we're achieving a throughput of 932,708,352 bits per second, or approximately 933 megabits per second. In my case the local zone is configured using a Crossbow VNIC, myzone0:
bleonard@opensolaris:~$ dladm show-vnic LINK OVER SPEED MACADDRESS MACADDRTYPE VID myzone0 e1000g0 1000 2:8:20:59:0:b5 random 0
Notice the link speed of myzone0 is 1000 megabits per second, and at the moment it's using just about every bit of that bandwitdh, potentially starving other virtual NICs and the physical NIC itself from the network. Fortunately, Crossbow allows me to put some reigns on my virtual NICs. For example, if I do the following:
pfexec dladm set-linkprop -p maxbw=200 myzone0
Above we can see we're now running just under 200 megabits per second. Or More ridiculously:
pfexec dladm set-linkprop -p maxbw=2 myzone0
We're now under 2 megabits per second.
Now it is also possible to drill down on the Chime display, graphing throughput over time. The above scenario looks like so:

If you want to check this out on your own environment, you only need the D script, Chime and the Network display:
- The DTrace script: so.d
- Chime
- The Chime display: Network.xml
<void property="programFileName"> <string>/export/home/bleonard/so.d</string> </void>
To launch the Chime display:
chime -C ./Network.xml
hello,
tested on solaris 10, it fails:
dtrace: failed to compile script ./so.d: line 27: undefined function name: inet_ntoa
is there a chance to have it working on solaris 10?
thanks
Posted by gerard on November 11, 2009 at 08:26 AM GMT #
Hi Gerard,
Solaris 10 is running DTrace API Version 1.3 (dtrace -V). OpenSolaris is running 1.6.2. Somewhere in between the inet_ntoa subroutine was added to DTrace. Specifically, it was addressed by this defect (http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6558517 ) in snv_66. Here's a change log that shows DTrace feature enhancements across the various builds (http://hub.opensolaris.org/bin/view/Community+Group+dtrace/ChangeLog ). Unfortunately, I don't know when, if ever, these changes will be back ported to Solaris 10.
Posted by Brian Leonard on November 11, 2009 at 04:36 PM GMT #
Hi,
This would be a great tool if I could get it working.
Im running snv_126, with dtrace API 1.6.2
I'm getting the followin error:
dtrace: failed to compile script ./so.d: line 20: operator -> must be applied to a pointer
line 20 looks like this:
self->uio_resid = self->uio->uio_resid;
Posted by Espen Martinsen on November 13, 2009 at 12:26 PM GMT #
Hi Espen,
The script runs fine for me on snv_126. Are you running SXCE? That could be our difference (although I can't imagine why that would matter).
/Brian
Posted by Brian Leonard on November 13, 2009 at 09:47 PM GMT #
Hi again,
no, I'm running "indiana". I'll have to investigate my environment, cause I just tried it on SXCE on a sparc, and there it worked fine.
-espenM
Posted by Espen Martinsen on November 13, 2009 at 10:43 PM GMT #
As there is more to networking than just bits per second, it might be worthwhile having a variation on the theme that can do packets per second.
Posted by rick jones on November 18, 2009 at 12:14 AM GMT #