diff --git a/fsm.c b/fsm.c
index b90dee5f2afc8e118612d1a7231b6920346b4402..8d39aa36788e5117dccffb892e0bba9fdf968876 100644
--- a/fsm.c
+++ b/fsm.c
@@ -228,8 +228,6 @@ int pp_state_machine(struct pp_instance *ppi, uint8_t *packet, int plen)
 		plen = 0;
 		packet = NULL;
 	}
-	if (!plen)
-		ppi->received_ptp_header.messageType = PPM_NO_MESSAGE;
 
 	state = ppi->state;
 
@@ -257,6 +255,8 @@ int pp_state_machine(struct pp_instance *ppi, uint8_t *packet, int plen)
 	if (ppi->state != ppi->next_state)
 		return leave_current_state(ppi);
 
+	if (!plen)
+		ppi->received_ptp_header.messageType = PPM_NO_MESSAGE;
 	err = ip->f1(ppi, packet, plen);
 	if (err)
 		pp_printf("fsm for %s: Error %i in %s\n",