5G wireless networks will support massive connectivity mainly due to device-to-device communications. An enabling technology for device-to-device links is the dynamical spectrum access. The devices, which are equipped with cognitive radios, are to be allowed to reuse spectrum occupied by cellular links. The dynamical spectrum availability makes cognitive users switch between channels. Switching leads to energy consumption, latency, and communication overhead in general. The performance degrades even more when the network is under jamming attack. This type of attack is one of the most detrimental attacks. Addressing jamming while maintaining a desired quality of service is a challenge. While existing anti-jamming mechanisms assume stationary users, in this paper, we propose and evaluate countermeasures for mobile cognitive users. We propose two time-based techniques, which, unlike other existing frequency-based techniques, do not assume accessibility to multiple channels and hence do not rely on switching to countermeasure jamming. We achieve analytical solutions of jamming, switching, and error probabilities. Based on our findings, the proposed techniques out perform other existing frequency-based techniques.