A cockroach's thorax attaches three pairs of legs. Each of the three pairs of legs is named after the region of the thorax to which it attaches:
The prothoracic legs are closest to the cockroach's head. These are the shortest legs, and they act like brakes when the roach runs. The middle legs are the mesothoracic legs. They move back and forth to either speed the roach up or slow it down.
The very long metathoracic legs are the cockroach's back legs, and they move the cockroach forward.
These three pairs of legs, are substantially different in lengths and functions, but they have the same parts and move the same way. The upper portion of the leg, called the coxa, attaches the leg to the thorax. The other parts of the leg approximate parts of a human leg:
The trochanter acts like a knee and lets the cockroach bend its leg.
The femur and tibia resemble thigh and shin bones.
The segmented tarsus acts like an ankle and foot. The hook-like tarsus also helps cockroaches climb walls and walk upside down on ceilings.