When you send,
- The sequence number of the reset packet should be the ack number of last received ACK packet.
- If you have not received any ACK packets then the sequence number should be zero, and the ack number should be the sum of the sequence number and the segment size. (You might be in SYN_SENT or CLOSED).
When you receive,
- A reset packet whose sequence number is in window range is valid.
Please look at page 36~37 of [RFC793]