The gravitational redshift

The equivalence principle says that the experience of acceleration and the experience of gravity are the same.
Here will will tip-toe in to general relativity and derive the surprising fact that a clock at the top of a building runs faster than a clock in the basement.  In place of a building we will consider a spaceship accelerating with constant proper acceleration g.

Let person A be at the back of a spaceship (xA=0) of proper length L, and person B be at the front (xB=L).
We let the spaceship accelerate at g for a short time, short enough that v/c is always small.
At t=0 A fires photon 1.  At (small) time T, A fires photon 2.

Your job: write expressions for the positions xB, x1 and x2, along the lines of the one given for xA:

xA[t_] = (1/2) g t^2
xB[t_] = 0+t (* this is wrong! -- fix *)
x1[t_] = 1-t
x2[t_] = 2-t

With the correct expressions in hand, the incantation below should give curves like these:

params = {c->1,g->1/5,T->1,L->1}
wlines=ParametricPlot[({{xA[t],t},{xB[t],t}}/.params),{t,0,3},PlotRange->{{0,2},{0,3}},PlotStyle->{Thick,Blue},AxesLabel->{"t","x"},Axes->False];
photons=ParametricPlot[({{x1[t],t},{x2[t],t}}/.params),{t,0,3},PlotRange->{{0,2},{0,3}},PlotStyle->{Dashed,Green}];
Show[wlines,photons,Graphics[{{Thick,Black,Arrow[{{1.5,0},{1.5,.5}}],Arrow[{{1.5,0},{2,0}}]},{Style[Text["t",{1.6,.6}],Bold,Large],Style[Text["x",{2.1,.1}],Bold,Large]}}/.params],PlotRange->{{0,2.2},{-.2,3}}]

Next, use Solve to find the time t1 at which photon 1 reaches B (i.e. x1[t]==xB[t]).
This is a quadratic equation with two roots.  Which root do you want here?  Define that one to be (Subscript[t, 1]).

Solve[xB[t]==c t,t]
t1=1 (*fix!*)

Likewise find the time when the second photon arrives at B.

t2 = 0  (*fix!*)

In the absence of acceleration the time difference t2-t1 (the difference in reception times) would just be T (the difference in emission times).  Here is how to check that:

Limit[t2-t1,g->0]

The small parameter is ϵ=gL/(c^2), so replace g-> ϵ c^2/L in (Subscript[t, 1]) and (Subscript[t, 2]) and ask for a Series to find the small effect:

(t2-t1)/.g->ϵ c^2/L
Series[%,{ϵ,0,1}]

This is the effect we are looking for: B receives the photons less often than A sends them,
or ... B says A's clock runs slow.

Suppose A starts out with synchronized clocks and accelerates for a short time T to
a speed v=gT.  In terms of v, by how much are the clocks out of sync, and which one
is ahead?  Is this in agreement with things you have learned about moving trains?