We introduce a method for efficient, in situ characterization of linear-optical networks (LONs) in randomized boson-sampling (RBS) experiments. We formulate RBS as a distributed task between two parties, Alice and Bob, who share two-mode squeezed-vacuum states. In this protocol, Alice performs local measurements on her modes, either photon counting or heterodyne. Bob implements and applies to his modes the LON requested by Alice; at the output of the LON, Bob performs photon counting, the results of which he sends to Alice via classical channels. In the ideal situation, when Alice does photon counting, she obtains from Bob samples from the probability distribution of the RBS problem, a task that is believed to be classically hard to simulate. When Alice performs heterodyne measurements, she converts the experiment to a problem that is classically efficiently simulable, but more importantly, enables her to characterize a lossy LON on the fly, without Bob's knowing. We introduce and calculate the fidelity between the joint states shared by Alice and Bob after the ideal and lossy LONs as a measure of distance between the two LONs. Using this measure, we obtain an upper bound on the total variation distance between the ideal probability distribution for the RBS problem and the probability distribution achieved by a lossy LON. Our method displays the power of the entanglement of the two-mode squeezed-vacuum states: the entanglement allows Alice to choose for each run of the experiment between RBS and a simple characterization protocol based on first-order coherence. Alice Classical channel Bob SPDC Classical channel SPDC SPDC LON Alice Bob C Q C Q C Q Q Q Q FIG. 1: M two-mode squeezed-vacuum states with the same squeezing parameter are generated by SPDC sources and shared between Alice and Bob. Bob inputs his modes to the LON, makes photon-counting measurements at the output of the LON, and sends the outcomes to Alice via a classical channel. Alice uses photon-counting measurements, denoted by Q, for the sampling runs of the RBS problem and makes heterodyne measurements, denoted by C, for characterizing Bob's LON. Because of the entanglement shared between the two parties, Alice can switch from a problem, based on photon counting, that is classically hard and not useful for characterization to a problem, based on heterodyne measurements, that is classically efficiently simulable and can be used for characterization.