public TCPHeader(ByteBuffer buffer) { this.sourcePort = BitUtils.GetUnsignedShort(buffer.Short); this.destinationPort = BitUtils.GetUnsignedShort(buffer.Short); this.sequenceNumber = BitUtils.GetUnsignedInt(buffer.Int); this.acknowledgementNumber = BitUtils.GetUnsignedInt(buffer.Int); this.dataOffsetAndReserved = (byte)buffer.Get(); this.headerLength = (this.dataOffsetAndReserved & 0xF0) >> 2; this.flags = (byte)buffer.Get(); this.window = BitUtils.GetUnsignedShort(buffer.Short); this.checksum = BitUtils.GetUnsignedShort(buffer.Short); this.urgentPointer = BitUtils.GetUnsignedShort(buffer.Short); int optionsLength = this.headerLength - TCP_HEADER_SIZE; if (optionsLength > 0) { optionsAndPadding = new byte[optionsLength]; buffer.Get(optionsAndPadding, 0, optionsLength); } }