Cocotb with scapy cosimulation
See original GitHub issueHi. I’ve been using Cocotb with scapy for simulating a tcp stack. Till now I’ve successfully run the ping/arp procedure. It’s TCP stack <=>MAC <=> cocotb <=> TAP device on wsl2 windows10 2004
This is the code I’m using for ping
@cocotb.coroutine
async def rgmii_sfuncion(a, b, c):
while True:
data = a.recv_raw()
crc = crc32(data[1])
rawdata = b'\x55\x55\x55\x55\x55\x55\x55\xD5' + data[1]
for i in range(4):
temp = (crc >> (8*i)) & 0xFF
rawdata += bytes([temp])
await b.send(rawdata)
await b.wait()
rx_frame = await c.recv()
#a.send(rx_frame.data[8:])
a.outs.write(rx_frame.data[8:])
It needs a packet send followed by a packet recv. So ping and arp works fine. I think.
So when it comes to tcp, the problem is how can I recv a packet while send a packet concurrently.
I’m thinking about
@cocotb.coroutine
async def rgmii_sfuncion(a, b, c):
while True:
data = a.recv_raw()
crc = crc32(data[1])
rawdata = b'\x55\x55\x55\x55\x55\x55\x55\xD5' + data[1]
for i in range(4):
temp = (crc >> (8*i)) & 0xFF
rawdata += bytes([temp])
await b.send(rawdata)
await b.wait()
#rx_frame = await c.recv()
#a.send(rx_frame.data[8:])
#a.outs.write(rx_frame.data[8:])
@cocotb.coroutine
async def rgmii_rfuncion(a, b, c):
while True:
rx_frame = await c.recv()
#a.send(rx_frame.data[8:])
a.outs.write(rx_frame.data[8:])
Is that work? I’ve tried the code before but no fortune.
But there may be a problem in the tcp stack.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Tutorial: Driver Cosimulation — cocotb 1.1 documentation
In this tutorial we will call unmodified production software from our testbench and re-use the code written to configure the entity. For the...
Read more >Cocotb: a Python-based digital logic verification framework
Cocotb is a library for digital logic verification in Python. Coroutine cosimulation testbench. Provides Python interface to control ...
Read more >cocotb, a coroutine based cosimulation library for writing ...
cocotb is a coroutine based cosimulation library for writing VHDL and Verilog testbenches in Python. Documentation Status CI PyPI Gitpod Ready-to-Code codecov.
Read more >Digital/Analog Cosimulation using CocoTB and Xyce
For interfacing with GHDL, we use CocoTB an open- source automated cosimulation and testbench library [1]. CocoTB is typically used for generating and...
Read more >cocotb(COroutine-based COsimulation TestBench) and ...
This video is all about how cocotb (COroutine-based COsimulation TestBench) environment help's for verifying Verilog/VHDL/System Verilog RTL ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m a such noob of python. My mistake. After surround both scapy read / write function with cocotb.external. Now it works like a charm.
Thankyou all for help. @ktbarrett @alexforencich @themperek
Ahh. I get the problem. Need sometime to figure it out. Update later. Close for now.