The first TCP was implemented in BCPL (precursor to the C programming language) for the TENEX operating system by Ray Tomlinson. While experimenting with this implementation to send files to a printer, Tomlinson found that data from old connections was getting mixed with data from new connections due to overlapping sequence numbers. This discovery led him to develop a theory of managing sequence numbers, in particular, creating a set of rules for when a particular sequence number can safely be reused and when its use is forbidden. His paper remains the standard reference today.
The initial TCP implementation was extremely slow; so slow that Bob Kahn expressed concern that TCP would never amount to anything. Bill Plummer of BBN re-implemented TCP in assembly code and put it into the operating system to improve memory performance by swiftly mapping pages. This TCP was used to experiment with a number of TCP features such as Desynchronize-Resynchronize (DSN-RSN) and Rubber End-of-Lines (used for record demarcation) that ultimately did not become part of the TCP standard.