title: TCP Sequence Number
body: <p>I'm trying to understand how the sequence numbers of the TCP header are generated.</p>
  <p>In some places I read that it is the &quot;index of the first byte in the packet&quot; (<a href="https://stackoverflow.com/questions/2672734/tcp-sequence-number-question">link here</a>), on some other sites it is a random 32bit generated number that is then incremented.</p>
  <p>I don't really know which is which, so here are some questions:</p>
  <ul>
  <li>How is the initial sequence number generated? (Please provide an RFC number if there is one)</li>
  <li>How is it incremented?</li>
  <li>How is the secret key generated?</li>
  </ul>
  <p>I read some of the RFCs like <a href="https://www.rfc-editor.org/rfc/rfc6528#section-2" rel="nofollow noreferrer">RFC 6528</a>, <a href="https://www.rfc-editor.org/rfc/rfc793" rel="nofollow noreferrer">RFC 793</a>, and <a href="http://www.networksorcery.com/enp/rfc/rfc1948.txt" rel="nofollow noreferrer">RFC 1948</a> but I can't seem to understand which one is actually implemented.</p>
  <p>I read about the &quot;std&quot; status but still...</p>
  <p>Thank you in advance!</p>