RTT is measured when transmitting segments, so there must be data in the sent packet so SYN and SYNACK can't provide a measurement.
The RFC says:
(5.1) Every time a packet containing data is sent (including a
retransmission), if the timer is not running, start it running...
So since in your example the client sends the first data then yes #4 acks it and provides a RTT measurement. Equally the server RTT measurement is made when #4 is acknowledged, a packet that you haven't shown (#5 perhaps)
It's in the first TCP RFC, RFC 793, TRANSMISSION CONTROL PROTOCOL, Section 3.7 Data Communication says:
An Example Retransmission Timeout Procedure
Measure the elapsed time between sending a data octet with a
particular sequence number and receiving an acknowledgment that
covers that sequence number (segments sent do not have to match
segments received). This measured elapsed time is the Round Trip
Time (RTT). Next compute a Smoothed Round Trip Time (SRTT) as:
SRTT = ( ALPHA * SRTT ) + ((1-ALPHA) * RTT)
and based on this, compute the retransmission timeout (RTO) as:
RTO = min[UBOUND,max[LBOUND,(BETA*SRTT)]]
where UBOUND is an upper bound on the timeout (e.g., 1 minute),
LBOUND is a lower bound on the timeout (e.g., 1 second), ALPHA is a
smoothing factor (e.g., .8 to .9), and BETA is a delay variance
factor (e.g., 1.3 to 2.0).
I haven't followed this through the updates so there may be better or more explicit references.