Provided the two signals have exactly the same known frequency (which you have indicated to be your case), you can estimate the delay and phase difference using the following steps:
- Estimate the relative time delay between the envelopes of the two pulses;
- Estimate the phase difference between each pulse and a reference (infinite length) tone at the specified frequency at an arbitrary time instant;
- Compute the relative phase of the delayed pulse based on the above estimated delay and phase differences.
For reference we can write the two pulses as:
$$
\begin{align}
y_1\left(t\right) &= \sin\left(2\pi f t\right) \cdot \Pi\left(\frac{t}{T}\right) \\
y_2\left(t\right) &= \sin\left(2\pi f (t-t_0) + \phi\right) \cdot \Pi\left(\frac{t-t_0}{T}\right) \\
\end{align}
$$
where $\Pi\left(t\right)$ is a rectangular pulse defined as:
$$
\Pi\left(t\right) =
\begin{cases}
1 &, 0\leq t\leq 1 \\
0 &, \mbox{otherwise}
\end{cases}
$$
1. Estimating the relative time delay between the envelopes of the two pulses
To do this, we must first estimate the envelope of the pulses $y_1\left(t\right)$ and $y_2\left(t\right)$. This can be achieved by using the complex analytical signals $\hat y_1\left(t\right)$ and $\hat y_2\left(t\right)$ given by:
$$
\begin{align}
\hat y_1\left(t\right) &= y_1\left(t\right) + j \mathcal{H}\left\{y_1\left(t\right)\right\}\\
\hat y_2\left(t\right) &= y_2\left(t\right) + j \mathcal{H}\left\{y_2\left(t\right)\right\}
\end{align}
$$
where $\mathcal{H}\left\{f\left(t\right)\right\}$ is the Hilbert transform of $f\left(t\right)$. The pulse envelopes estimated are then obtained from $\left|\hat y_1\left(t\right)\right|$ and $\left|\hat y_2\left(t\right)\right|$. Finally, the time delay between the two pulses can be obtained from the peak of the cross-correlation between those two envelope estimates.
2. Estimating the phase difference between each pulse and a reference tone
Given the two complex analytical signals $\hat y_1\left(t\right)$ and $\hat y_2\left(t\right)$ obtained earlier, computing the complex baseband signals
$$
\begin{align}
z_1\left(t\right) &= \hat y_1\left(t\right) \cdot e^{-j 2\pi f t} \\
z_2\left(t\right) &= \hat y_2\left(t\right) \cdot e^{-j 2\pi f t}
\end{align}
$$
readily gives us the phase differences between the pulses and the (complex) reference tone $e^{j 2\pi f t}$ as $\angle z_1\left(t\right)$ and $\angle z_2\left(t\right)$ respectively. Note that to reduce the estimation error it is also possible to use the angle of the average complex baseband signal over the pulse duration.
3. Computing the relative phase of the delayed pulse
Since both phase differences are expressed relative to the same complex reference tone, and looking at the expression for the phase of the original pulses $y_1\left(t\right)$ and $y_2\left(t\right)$, the phase difference between the two pulses can be seen to be:
$$
\begin{align}
\angle z_2\left(t\right) - \angle z_1\left(t\right)
&= - 2\pi f t_0 + \phi + 2\pi k
\end{align}
$$
from which we derive that
$$
\begin{align}
\phi
&= \angle z_2\left(t\right) - \angle z_1\left(t\right)
+ 2\pi f t_0 + 2\pi k'
\end{align}
$$
Demonstration
This can be demonstrated using the following Matlab script:
clear all;
close all;
% Simulation parameters
K = 40;
f = 1e6; % tone at 1MHz
fs = K*f; % sampling rate
T = 5e-6; % 5 microsecond pulse
d = 1e-6; % second pulse's delay (wrt first pulse)
phi = 2*pi*rand; % second pulse's phase difference (wrt first pulse)
% Generate pulses
t = [0:1/fs:T];
N = length(t);
M = floor(1.5*(T+d)*fs);
y1 = zeros(1,M);
y1(1:N) = sin(2*pi*f*t);
y2 = zeros(1,M);
offset = floor(d*fs);
y2([1:N]+offset) = sin(2*pi*f*t + phi);
tt = [0:M-1]/fs;
% 1. Estimating the relative time delay between the envelopes of the two pulses
y1hat = hilbert(y1); % complex analytical envelope of y1
y2hat = hilbert(y2); % complex analytical envelope of y2
env1 = abs(y1hat); % estimated envelope of y1
env2 = abs(y2hat); % estimated envelope of y2
[r,lag]=xcorr(env2,env1);
[rmax,idxmax]=max(r);
lagmax = lag(idxmax);
delay = lagmax / fs;
% 2. Estimating the phase difference between each pulse and a reference tone
z1 = y1hat .* exp(-2*pi*f*tt*i);
z2 = y2hat .* exp(-2*pi*f*tt*i);
% Integrate the signal (averaging) to reduce estimation error
w1 = zeros(size(z1));
w2 = zeros(size(z2));
w1(1) = z1(1);
w2(1) = z2(1);
for i=2:length(z1)
w1(i) = w1(i-1) + z1(i);
w2(i) = w2(i-1) + z2(i);
end
%3. Computing the relative phase of the delayed pulse
% Sample the result near the end of the pulses
Ns1 = floor(0.95*N) + 1;
Ns2 = Ns1 + lagmax;
phasediff = mod(angle(w2(Ns2))-angle(w1(Ns1))+2*pi*f*delay, 2*pi);
% Show results
printf("Actual parameters\n");
printf(" phase difference : %f\n", phi);
printf(" time delay : %e\n", d);
printf("Estimated parameters\n");
printf(" phase difference : %f\n", phasediff);
printf(" time delay : %e\n", delay);