ByteBuffer completeBuf = ByteBuffer.allocate(completeBufSize);
BufferUtil.clearToFill(completeBuf);
// Generate from all frames
Generator generator = new UnitGenerator();
for (Frame f : frames)
{
ByteBuffer header = generator.generateHeaderBytes(f);
totalBytes += BufferUtil.put(header,completeBuf);
if (f.hasPayload())
{
ByteBuffer payload=f.getPayload();