Man in the middle attack

How to detect a Man in the Middle (MITM) attack on Wi-Fi network and disconnect that network using objective-c