The large high-altitude air shower observatory (LHAASO) is being built near Daocheng (4410 m a.s.l.) in the Sichuan province of China. Its main instrument is the one-kilometer square extensive air shower array (KM2A) which will comprise nearly 7000 detectors. The system adopts a distributed architecture where each detector has local front-end electronics for signal digitization and transmission. White Rabbit (WR) is the communication protocol used within KM2A to reach the required 1-ns synchronization accuracy between detectors. To provide data transport and synchronization over the same network. We have developed a firmware implementation of the TCP/IP protocol in Verilog hardware description language that can be coupled with a WR intellectual property core. LHAASO KM2A distributed data and clock synchronization network meets the high requirement of the array for reliable data transmission and clock synchronization. The data transmission method based on the TCP/IP protocol suite and WR can be run in Xilinx Spartan6 FPGA with low resource needs, which greatly expand its application field.