Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to reliably generate Ethernet frame errors in software?
    primarykey
    data
    text
    <h1>Question:</h1> <p>I'm testing a section of cable-fault finding software, and I'd like to reliably and reproducibly generate cable faults on a cat5 cable. </p> <p>At the moment I'm using a meter length of untwisted cable, and wriggle the cable manually next to a power supply, but I cannot detect any faults in the application (I'm reading the Ethernet fault counters off the Ethernet ASIC.) Whether this is because no faults are generated, or because the software/hardware detection is faulty, I cannot tell.</p> <p>Is there a way to do this in software? </p> <p>I'd settle for writing something in a higher level language, like Java or python, and as a last resort would be willing to put it together in C, but I'd really rather not re-write an Ethernet driver purely to fix a possible bug.</p> <p><strong>[EDIT]:</strong> I want to <strong>create</strong> cable faults - not detect them.</p> <p><strong>[EDIT]:</strong> I've transferred large files through FTP and SCP without problems with the doctored cable, and I see no errors coming up while inspecting the traffic with wireshark</p> <p><strong>[EDIT]:</strong> See also a <a href="https://stackoverflow.com/questions/723635/how-do-you-send-an-ethernet-frame-with-a-corrupt-fcs">similar question in python</a>.</p> <h1>Solution:</h1> <p>Well, after spending over a day fighting with C, this is the python solution.</p> <p>First disable automatic checksumming of the ethernet card:</p> <pre><code>sudo ethtool -K eth1 tx off </code></pre> <p>Then, send your dodgy frame from python:</p> <pre><code>#!/usr/bin/env python from socket import * # # Ethernet Frame: # [ # [ Destination address, 6 bytes ] # [ Source address, 6 bytes ] # [ Ethertype, 2 bytes ] # [ Payload, 40 to 1500 bytes ] # [ 32 bit CRC chcksum, 4 bytes ] # ] # s = socket(AF_PACKET, SOCK_RAW) s.bind(("eth1", 0)) src_addr = "\x01\x02\x03\x04\x05\x06" dst_addr = "\x01\x02\x03\x04\x05\x06" payload = ("["*30)+"PAYLOAD"+("]"*30) checksum = "\x00\x00\x00\x00" ethertype = "\x08\x01" s.send(dst_addr+src_addr+ethertype+payload+checksum) </code></pre> <p>Who said it had to be complicated...</p> <p>PS: <em>I Love Python.</em></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload