TCP traffic generator based on tunnel.py example

Hi:

Lately, I am implementing different MAC protocols based on the tunnel
example. In order to test the performance, I want to generate TCP
traffic packets and pass them to MAC protocols/PHY and send out like how
tunnel example works. But I am confused about how to generate TCP
packets. I saw some people use TCP socket with file_descriptor
source/sink function. However, if I use TCP socket, then the packets
won’t pass the MAC protocols I designed. Am I right? Or how should I
generate TCP packets based on my application?

Thank for ur help in advance!
KC Huang