Real-time traffic control in railway systems