This paper presents a new optimal bandwidth allocation method for networked control systems using a hidden Markov model (HMM) to predict network traffic states, which allows for efficient resource management in a constrained network environment. The methodology focuses on improving bandwidth allocation by utilizing l1 minimization and adapting to varying traffic conditions while ensuring system stability through a derived stability condition. Simulation results demonstrate that the proposed HMM-based approach outperforms traditional fuzzy logic methods in terms of resource allocation efficiency.