function calculate_trailer() { // The trailer is just the top of the body plus some crap $body = $this->body_start(); return $body . chr(4) . chr(0xff) . pack('N', strlen($body)); }