Guide 078 min readFrameAssembly v3.1.2
llms-full.txt

Physical Hardware Labs: Blasting .pcap Captures onto Real Copper & Fiber (tcpreplay)

Wire .frasm -> .pcap captures into SPAN ports, optical TAPs, two-NIC firewall hairpins (tcpprep + tcpreplay), and managed switch trunks without NIC drivers eating your VLAN tags.

TL;DR — What Matters Here
  • FrameAssembly never touches raw sockets: it writes .pcap files in user space, and tcpreplay / Bittwist / Ostinato blasts those bytes onto real copper or SFP+ fiber.
  • Two-NIC hairpins (eth1 -> Trust, eth2 <- Untrust) let one Linux box impersonate both client and server across a hardware firewall via tcpprep + tcpreplay.
  • Turn off Linux NIC VLAN-stripping offloads (ethtool -K eth1 rxvlan off txvlan off) before replaying 802.1Q, QinQ, or deliberately weird anomaly packets.

1. SPAN Ports, Optical TAPs & Passive NDR / OT Sensors

Standing up a hardware IDS/NDR box (Suricata, Zeek, Corelight, ExtraHop) or an industrial OT sensor (Claroty, Dragos, Nozomi) hanging off a SPAN port or passive fiber TAP? Plug one spare lab NIC straight into the monitor port and feed it a classic .pcap.

Because passive sensors never talk back, your .frasm script has to carry *both* sides (-> and <-) of the TCP handshake so the stream reassembler marks the flow established before inspecting TLS SNI, HTTP, SMB, or Modbus.

span_sensor_audit.frasm14 lines
Open in Playground
// Bidirectional VLAN 120 trace -> physical SPAN / optical TAP sensor port
host branch_ws { ip 10.20.15.42 mac 00:50:56:aa:15:42 }
host shadow_edge { ip 198.51.100.84 mac 00:1c:73:00:00:01 }
compile {
// Full 3-way handshake -> stream reassembler marks flow established
branch_ws -> shadow_edge tcp syn srcport 54210 dstport 443 win 65535 mss 1460 vlan 120 wait 1ms
branch_ws <- shadow_edge tcp syn ack win 65535 mss 1460 vlan 120 wait 1ms
branch_ws -> shadow_edge tcp ack vlan 120 wait 1ms
// TLS 1.3 ClientHello SNI + HTTP/3 QUIC Initial probe
branch_ws -> shadow_edge tls clienthello sni "unmanaged-transfer.example.net" alpn "h2" vlan 120 wait 2ms
branch_ws -> shadow_edge quic initial version 1 dcid 0x1122334455667788 scid 0xaabbccddeeff0011 pktnum 1 vlan 120
}
Terminal Commands (FrameAssembly CLI v3.1.2)
# 1. Compile classic microsecond .pcap (what tcpreplay expects)
frameassembly span_sensor_audit.frasm span_sensor_audit.pcap

# 2. Bring up your spare lab NIC and fire away
sudo ip link set dev eth1 up
sudo tcpreplay --intf1=eth1 --pps=500 span_sensor_audit.pcap

2. Two-NIC Hardware Firewall Hairpin (eth1 -> NGFW <- eth2)

Blast a two-way .pcap out of *one* NIC into a stateful Layer 3 hardware firewall (Palo Alto, FortiGate, SRX, Firepower) and watch every server reply die horribly on the Trust port thanks to Reverse Path Forwarding (RPF) and zone checks.

The bench trick: cable two NICs on your Linux tester (eth1 -> Firewall Trust, eth2 -> Firewall Untrust/DMZ). Toss two gratuitous arp frames at the top so the firewall doesn’t stall ARPing for fake hosts, set dstmac to each ingress interface MAC, and let tcpprep + tcpreplay split client <-> server across both cables:

inline_ngfw_hairpin.frasm20 lines
Open in Playground
// Two-NIC inline L3 firewall bench:
// eth1 -> Firewall Trust: 10.10.1.1 mac 00:1b:17:00:01:01
// eth2 -> Firewall Untrust: 172.16.2.1 mac 00:1b:17:00:02:01
host trust_client { ip 10.10.1.50 mac 02:00:00:10:01:50 }
host dmz_server { ip 172.16.2.80 mac 02:00:00:16:02:80 }
host fw_trust { ip 10.10.1.1 mac 00:1b:17:00:01:01 }
host fw_untrust { ip 172.16.2.1 mac 00:1b:17:00:02:01 }
compile {
// 1. Seed firewall ARP tables on Trust (eth1) and Untrust (eth2)
trust_client -> fw_trust arp gratuitous wait 5ms
dmz_server -> fw_untrust arp gratuitous wait 5ms
// 2. Stateful TCP + HTTP flow addressed to each firewall ingress MAC
trust_client -> dmz_server tcp syn srcport 52100 dstport 8080 win 65535 mss 1460 dstmac 00:1b:17:00:01:01 wait 1ms
dmz_server -> trust_client tcp syn ack srcport 8080 dstport 52100 seq 5000 acknum 1001 win 65535 mss 1460 dstmac 00:1b:17:00:02:01 wait 1ms
trust_client -> dmz_server tcp ack srcport 52100 dstport 8080 seq 1001 acknum 5001 dstmac 00:1b:17:00:01:01 wait 1ms
trust_client -> dmz_server http get uri "/api/v1/health" hosthdr "dmz-api.lab.local" srcport 52100 dstport 8080 seq 1001 acknum 5001 dstmac 00:1b:17:00:01:01 wait 2ms
dmz_server -> trust_client http status 200 reason "OK" body "{\"zone\":\"dmz\"}" srcport 8080 dstport 52100 seq 5001 acknum 1072 dstmac 00:1b:17:00:02:01
}
Terminal Commands (FrameAssembly CLI v3.1.2)
# 1. Compile classic .pcap
frameassembly inline_ngfw_hairpin.frasm inline_ngfw_hairpin.pcap

# 2. Split client (10.10.1.0/24 -> eth1) vs server (everything else -> eth2)
tcpprep --cidr=10.10.1.0/24 --pcap=inline_ngfw_hairpin.pcap --cachefile=hairpin.cache

# 3. Replay synchronously across Trust (eth1) <-> Untrust (eth2)
sudo tcpreplay --cachefile=hairpin.cache --intf1=eth1 --intf2=eth2 inline_ngfw_hairpin.pcap
Virtual-Wire (vwire) Mode Is Even Lazier

Put your lab firewall in Layer 2 Virtual-Wire / transparent bridge mode between eth1 and eth2 and you can skip all the dstmac overrides — plain -> and <- arrows work out of the box.

3. Managed Switch Ports: LLDP, 802.1X EAPOL & QinQ Trunks

Cabling a lab NIC straight into a Cisco Catalyst/Nexus, Arista, Juniper, or MikroTik port lets you test show lldp neighbors, 802.1X eapol port auth, Dynamic ARP Inspection (DAI), and carrier 802.1ad QinQ trunks.

Because all 8 pure Layer 2 protocols (arp, vlan, qinq, lldp, stp, lacp, eapol, mpls) accept MAC-only host blocks, you don’t even need dummy IPs for L2 bring-up:

switch_port_bringup.frasm17 lines
Open in Playground
// Direct switch-port poke: LLDP + 802.1X EAPOL + QinQ double-tag
host lab_nic { mac 00:1b:21:aa:bb:01 }
host tor_sw_01 { mac 00:1c:73:00:09:99 }
host cpe_edge { ip 172.20.40.10 mac 00:1b:21:aa:bb:02 }
host pe_core { ip 172.20.40.1 mac 00:1c:73:00:09:98 }
compile {
// 1. Light up 'show lldp neighbors'
lab_nic -> tor_sw_01 lldp chassisid "lab-tester-01" portid "eth1" ttl 120 sysname "packet-bench.lab" wait 5ms
// 2. Wake up 802.1X authenticator on the switch port
lab_nic -> tor_sw_01 eapol start version 2 wait 5ms
lab_nic -> tor_sw_01 eapol eappacket version 2 eapcode 2 eapid 1 eapmethod 1 identity "host/bench01.corp.local" wait 5ms
// 3. Test 802.1ad QinQ S-VLAN 2100 -> C-VLAN 40 handoff
cpe_edge -> pe_core icmp echorequest id 77 seq 1 qinq 2100 innervlan 40 pcp 5
}

4. Five Ways a Physical NIC or Switch Will Quietly Sabotage You

Before blaming your .frasm script when packets vanish on copper, check these five hardware traps:

Terminal Commands (FrameAssembly CLI v3.1.2)
# Turn off Linux NIC VLAN-tag eating & segmentation offloads on your replay port
sudo ethtool -K eth1 rxvlan off txvlan off tx off rx off tso off gso off gro off

# Bump MTU so QinQ (+8B) or VXLAN (+50B) doesn't hit errno=90 (Message too long)
sudo ip link set dev eth1 mtu 1558
Hardware TrapWhat Goes SidewaysFix
NIC VLAN offload (txvlan on)Outer vlan or qinq tags vanish or mutate on the wiresudo ethtool -K eth1 txvlan off rxvlan off before tcpreplay.
1500 byte NIC MTUtcpreplay complains Message too long (errno=90) on QinQ / VXLAN framesRaise replay NIC + switch port MTU (1508 QinQ, 1558+ VXLAN, or 9000 jumbo).
Switch bpduguardSending one stp BPDU instantly slams your switch port into err-disabledOnly fire stp frames into isolated lab ports where BPDU Guard is what you are testing!
Burst rate vs wait timersHardware policer drops zero-gap burstsDefault tcpreplay honors .frasm wait deltas; add --pps=100 for gentle pacing.
Windows laptopsNo native AF_PACKET socket for tcpreplayUse Npcap (with raw 802.1Q enabled) + Ostinato/Bittwist, or pass a USB NIC into Linux.