memcachedMemcached ASCII & Binary Cache ProtocolCache Lookups & UDP 11211 Amplification Checks (memcached)
What It Does on the Wire
Infamous for 51,000x UDP 11211 reflection attacks: memcached includes the 8-byte Memcached UDP frame header by default and drops cleanly onto raw TCP stream framing when you add transport tcp.
Memcached (memcached) serves distributed in-memory key-value caches on port 11211. Historically, exposed UDP port 11211 servers caused record-breaking 51,000x DDoS reflection attacks (via the 8-byte Memcached UDP frame header + stats / get), whereas production internal clusters run over TCP port 11211 (transport tcp) using either the ASCII text protocol or the 24-byte Binary protocol (0x80/0x81).
FrameAssembly supports all four combinations: UDP or transport tcp, and ASCII (get, set, cmd "stats") or Binary (opcode 0x00, opaque, cas).
Verify Perimeter UDP 11211 DDoS Amplification Blocks
Send memcached cmd "stats" on UDP 11211 (automatically carrying the 8-byte Memcached UDP request header) to confirm border ACLs and scrubbing rules drop UDP 11211.
Test Internal Microservice TCP 11211 Cache Flows
Use transport tcp with set and get to validate VPC security groups and service-mesh policies.
Memcached Binary Protocol (0x80) Dissector Validation
Specify opcode 0x00 (Binary Get) or opcode 0x01 (Binary Set) with opaque and cas fields to test binary packet analyzers.
Minimal Quickstart (memcached_quickstart.frasm)
Hit Preview Packets to compile in-browser and eyeball timestamps + wire byte lengths, or ship it straight to the Playground.
host web_app { ip 10.45.1.15 }host cache_pool { ip 10.45.1.112 }compile { web_app -> cache_pool tcp syn srcport 51211 dstport 11211 wait 1ms web_app <- cache_pool tcp syn ack wait 1ms web_app -> cache_pool tcp ack wait 1ms web_app -> cache_pool memcached set key "user:profile:42" value "{\"tier\":\"pro\"}" exptime 300 transport tcp}What the Compiler Calculates So You Don't Have To
- Prepends the mandatory 8-byte Memcached UDP frame header (
Request ID,Seq 0,Total Datagrams 1,Reserved 0) automatically on UDP11211, and omits it cleanly whentransport tcpis set. - Formats exact
<byte_len> <value>blocks on ASCIIsetcommands. - Switches to the 24-byte
0x80Memcached Binary Protocol header wheneveropcodeis specified.
UDP 11211 stats Amplification Audit + TCP ASCII & Binary Cache Operations
Tests a UDP 11211 stats probe, then opens a TCP 11211 session exercising both ASCII set/get and Binary (opcode 0x00) get.
host auditor { ip 172.16.45.10 }host memcache { ip 172.16.45.112 }compile { // 1. UDP 11211 amplification audit probe (with 8-byte UDP header) auditor -> memcache memcached cmd "stats" wait 4ms // 2. Authorized internal TCP 11211 session (ASCII + Binary) auditor -> memcache tcp syn srcport 53211 dstport 11211 win 65535 mss 1460 wait 1ms auditor <- memcache tcp syn ack win 65535 mss 1460 wait 1ms auditor -> memcache tcp ack wait 1ms auditor -> memcache memcached set key "cfg:feature_x" value "enabled" flags 0 exptime 600 transport tcp wait 2ms auditor -> memcache memcached get key "cfg:feature_x" opcode 0x00 opaque 0x99 transport tcp}# 1. Eyeball relative timestamps, ports & wire lengths in your terminal
frameassembly show memcached_udp_and_tcp.frasm
# 2. Compile .frasm -> classic .pcap (tcpdump/tcpreplay/Suricata) or nanosecond .pcapng
frameassembly memcached_udp_and_tcp.frasm memcached_udp_and_tcp.pcap
frameassembly memcached_udp_and_tcp.frasm memcached_udp_and_tcp.pcapng
# 3. Round-trip .pcap <-> .frasm whenever you want to scrub or tweak an existing capture
frameassembly reverse memcached_udp_and_tcp.pcap memcached_udp_and_tcp_edited.frasmAll memcached Keywords & Header Options
Every sub-keyword and header option is lowercase [a-z0-9]+ with zero underscores — mix and match them in any order after memcached:
src_host -> dst_host memcached [get | set | cmd "<text>"] [key "<text>"] [value "<text>"] [flags <number>] [exptime <number>] [opcode <hex_or_num>] [opaque <hex_or_num>] [cas <hex_or_num>] [transport <udp|tcp>]| Keyword / Option | Accepted Value | Default | Effect on Packet |
|---|---|---|---|
| get | set | cmd "<text>" | ASCII Memcached command (get, set, cmd "stats", cmd "delete") | get | Selects the ASCII command line. |
| key "<text>" | value "<text>" | Quoted cache key (no spaces) and payload value | key "test" | Populates key and data block bytes in ASCII or Binary frames. |
| flags <number> | exptime <number> | 32-bit client flags + TTL expiration in seconds | flags 0, exptime 0 | Sets flags and exptime in set requests. |
| opcode <hex_or_num> [opaque <hex_or_num>] [cas <hex_or_num>] | Binary protocol opcode (0x00 Get, 0x01 Set, 0x07 Quit) | Omitted (uses ASCII mode) | Switches the packet to the 24-byte 0x80 Memcached Binary Protocol. |
| transport <udp|tcp> | udp or tcp | udp | Switches between UDP 11211 (8-byte UDP header) and TCP 11211. |
Cross-Layer Wrappers Valid with memcached
802.1Q VLAN / QinQ / MPLS tags, IPv4/IPv6 QoS & TTL fields, wait gaps, and transport overrides allowed on this protocol
12 options
Cross-Layer Wrappers Valid with memcached
802.1Q VLAN / QinQ / MPLS tags, IPv4/IPv6 QoS & TTL fields, wait gaps, and transport overrides allowed on this protocol
| Option | Range / Format | Default | Effect on Packet |
|---|---|---|---|
| wait <number><ns|us|ms|s|m> | Time gap (ns, us, ms, s, m) | 10ms | Advances the packet timestamp clock after sending this packet and before the next packet (wait 0ns sends back-to-back). |
| payload "<text>" | hexpayload "<hex>" | Quoted text or hex bytes (choose one) | Omitted | Appends or overrides raw payload bytes ("deadbeef" or "de:ad:be:ef") and updates packet lengths and checksums. |
| srcmac <mac> | dstmac <mac> | Colon, hyphen, or Cisco dot MAC | Host MAC / RFC multicast MAC | Overrides the 14-byte Ethernet II source or destination MAC address for this single packet. |
| vlan <0..4095> [pcp <0..7>] [dei <0|1>] | VLAN ID 0..4095, PCP 0..7, DEI 0..1 | Untagged | Wraps the packet in an IEEE 802.1Q VLAN tag (0x8100) with optional 802.1p QoS priority. |
| qinq <0..4095> [innervlan <0..4095>] | Outer S-VLAN 0..4095, Inner C-VLAN 0..4095 | Untagged (innervlan 1 when qinq is set) | Double-tags the packet with outer IEEE 802.1ad S-Tag (0x88a8) plus inner IEEE 802.1Q C-Tag (0x8100). |
| mpls <0..1048575> [exp|tc <0..7>] [bos <0|1>] [mplsttl <0..255>] | Label 0..1048575, exp/tc 0..7, bos 0..1, ttl 0..255 | Unlabeled (at most 1 mpls tag per packet) | Inserts a 32-bit MPLS label header (0x8847) ahead of the Layer 3 header. |
| ttl <0..255> [dscp <0..63>] [ecn <0..3>] | TTL/Hop Limit 0..255, DSCP 0..63, ECN 0..3 | ttl 64, dscp 0, ecn 0 | Sets IPv4 TTL or IPv6 Hop Limit plus DiffServ (DSCP) and ECN QoS markings. |
| ipid <0..65535> [df] [mf] [fragoffset <0..8191>] | IPv4 ID, DF/MF flags, fragment offset 0..8191 | ipid 1, flags 0, fragoffset 0 | Sets IPv4 Identification, Do-Not-Fragment (df), More-Fragments (mf), and fragment offset (ignored over IPv6). |
| flowlabel <0..1048575> | 20-bit IPv6 Flow Label (0..1048575) | 0 | Sets the 20-bit IPv6 Flow Label for ECMP routing tests (ignored when running over IPv4 hosts). |
| srcport <0..65535> | dstport <0..65535> | Port number 0..65535 | srcport 49152 (remembered), UDP 11211 (or TCP 11211 via transport tcp) | Overrides source or destination port and remembers the port pair automatically on <- replies. |
| transport <tcp|udp> | tcp or udp (supported on 9 dual-L4 protocols) | transport udp | Switches Layer 4 transport between TCP (psh ack + length framing where required) and UDP. |
| seq <number> | acknum <number> | win <0..65535> | syn | ack | psh | fin | rst | TCP sequence/ack numbers, window size, flags & RFC 7323 options | psh ack, win 65535, automatic TCP seq/acknum | When using TCP (transport tcp or default TCP): overrides automatic TCP sequence tracking, flags, or mss/wscale/sackperm/tsval/tsecr. |
Gotchas & Quick Fixes
Memcached ASCII Keys Cannot Contain Spaces
web_app -> cache_pool memcached get key "user profile 42" transport tcpweb_app -> cache_pool memcached get key "user:profile:42" transport tcpMemcached’s ASCII protocol uses whitespace to separate tokens on the command line; use colons or hyphens inside keys.