We did something similar here but not for bandwidth usage. It might prove helpful. We took a filehandle and did a tie() on it, and selected it as the default output filehandle.
Using something like this you could count the bytes that go by unobtrusively and then when the object is destroyed (the program ends), put the data out to a logfile somewhere..