you will need to read the TCP standard.  TCP was first defined in RFC 793.  A link to this document is provided. https://tools.ietf.org/html/rfc793