Assuming you have a functioning ground in each box, which is not 100% guaranteed, but should be the case for any 1960s or later house, and many earlier ones as well, and
assuming your 3-way switch setup is as drawn: Panel -> Switch 1 -> Switch 2 -> Fixture
- Turn off the breaker.
- Check each wire for continuity with ground (ground wire or metal box).
When all wires are connected properly you should have exactly one wire in each cable that is continuous (or extremely low resistance) with ground. That is your neutral wire. The other 2 wires in each cable are then, by definition, travelers.
However, while the first assumption (ground present everywhere) is a pretty reasonable one, the second assumption (simplest 3-way switch configuration) is NOT a safe assumption to make without a lot more details. In addition to some other more complicated scenarios and some non-code-compliant scenarios, there are two very common 3-way switch configurations which do not match your diagram:
- Power -> Fixture -> Switch 1 -> Switch 2
In this case, neutral connects from the incoming power line at the fixture and hot and switched hot go down to Switch 1 and the /3 cable could be hot/travelers or switched hot/travelers.
- Power -> Switch 1 -> both Switch 2 and Fixture
In this case, the Switch 1 box sends neutral directly from the incoming power line to the fixture and the /3 cable could be hot/travelers or switched hot/travelers.
A lot can be figured out by:
- Identify which cable is incoming hot (turn off the breaker, mark and disconnect all wires from switch 1 and switch 2, turn on the breaker and check each wire with a non-contact voltage tester - the one hot wire is the incoming hot and should be paired with the incoming neutral)
- The number of cables in each box will determine the rest. /2 + /3 in switch 1 and /2 + /3 in switch 2 will match Power -> Switch 1 -> Switch 2 -> Fixture. /2 + /3 + /2 in Switch 1, /3 in Switch 2 will match Power -> Switch 1 -> Switch 2 and Fixture, etc.