This paper proposes an algorithm for the dynamic assignment of Restricted Access Window (RAW) for IEEE 802.11 ah. The Internet of Things (IoT) has groups of sensors and stations interacting over a common network. Wireless Local Area Network (WLAN) standard IEEE 802.11ah is best for IoT because it has high data rate and wide coverage while consuming low power. IEEE 802.11ah uses cautiously selected fixed RAW through an Access Point (AP), so that the chances of packet collision is minimized and energy efficiency is improved. By keeping it static, however, the effectiveness of RAW to utilize channels is reduced. We are suggesting an algorithm in which AP roughly calculates network packet transmission and the number of transmitting stations, and assigns resources to IoT networks by modifying RAW dynamically. The proposed algorithm shows improvement in average delay, throughput, PDR and jitter. The proposed algorithm achieves one of the best performances with an average delay of 0.43 sec, throughput of about 23 kbps, maximum packet delivery ratio (PDR) of about 98%, and jitter of about 80 sec.