-
Notifications
You must be signed in to change notification settings - Fork 1
TFTP ackPacket
Elbasiouny, Mahmoud edited this page Mar 6, 2026
·
5 revisions
ACK packets (opcode 4) acknowledge the receipt of a DATA packet. They are the simplest TFTP packet type - just an opcode and a block number.
Source file:
tftp.c
Hammer concepts:h_int_range·h_sequence
2 bytes 2 bytes
+---------+---------+
| Opcode | Block # |
+---------+---------+
According to the RFC:
- Opcode - 2 bytes, value 4
- Block # - 2 bytes, the block number being acknowledged (range 0–65535)
A block number of 0 is used to acknowledge a WRQ before any DATA packets are sent.
H_RULE(opc, h_int_range(h_uint16(), 4, 4));This only accepts a value of exactly 4.
H_RULE(blockNum, h_int_range(h_uint16(), 0, UINT16_MAX));Unlike DATA packets (which start at 1), ACK block numbers start at 0.
H_RULE(ackPacket, h_sequence(opc, blockNum, h_end_p(), NULL));h_end_p() ensures there are no extra bytes after the block number, since an ACK packet is exactly 4 bytes.
| Concept | Hammer Function | Why It Matters in TFTP |
|---|---|---|
| Exact value match | h_int_range(p, 4, 4) |
Opcode must be exactly 4 |
| Full range | h_int_range(p, 0, MAX) |
Block number can be 0–65535 |
| Parse in order | h_sequence |
Opcode followed by block number |
Next: ERROR Packets
Previous: DATA Packets
Learn Hammer
Protocol Examples
NTP
- NTP Overview
- Parsing the Header
- Parsing Data Fields
- Extension Fields and MAC
- Assembling the Parser
- Hex Input Preprocessing
- Running and Testing
DNS
TFTP
- TFTP Overview
- RRQ/WRQ Packets
- DATA Packets
- ACK Packets
- ERROR Packets
- Assembling the Parser
- Running and Testing
References
- Hammer Quick Reference
- Parsing Backends
- Unit Testing
- Using RTEMS
- Extending Hammer
- Adding a New Example
- Adding a New Binding
Further Reading