code: def write_header(self):
          
  
          self.output.seek(0)
          self.output.write(struct.pack('!HHHHHH', self.id, self.flags,
                                        self.counts[0], self.counts[1],
                                        self.counts[2], self.counts[3]))
          self.output.seek(0, 2)
docs: Write the DNS message header.
  
          Writing the DNS message header is done asfter all sections
          have been rendered, but before the optional TSIG signature
          is added.