You need to implement the connection establishment and termination. The best way is to implement it using the standard TCP states. (At the minimum, and for less credit, implement only the ``common'' case.)
Once the connection is established (we reached the establish state) we will use a very non-standard approach to implement TCP.
You implementation will include two components. One component will be responsible for deciding when to send a segment. The other component will decide which segment to send. The when component will decide when a segment can be sent, and forward a signal to the which component, that will decide which segment to send over the connection.
For the when component you can use any reasonable approach. Here are two basic alternatives, with a similar flavor. They both have a counter that keeps how many credits we have to send segments, and each time we send a segment we reduce the counter by one (or the number of bytes sent). A segment can be sent only if there is sufficient credits for it.
The parameters should be adjusted to reflect the load, and this should be done dynamically. (However, at the first stage, start with fix parameters, and only once you got it to work, implement the dynamic modification of the parameters.)
For the which component you are also free to chose your design. The two things to keep in mind is that you should resend old segments, since they might get lost, and you should send ``new'' segments, to keep the throughput high. Here are some alternatives.