My guess is, both Pakistan and North Korea are playing for the Chinese. The Chinese can't impose a war on its neighbors just because a war will definitely end their race towards becoming the well-established number two economic power in the world. Through the confrontations against the USA by Pakistan and North Korea, China is keeping the USA away from focusing on its own ambitions as the biggest (because its own people are quite powerless against the leadership unlike the US people) global power in the world one day.
By engaging the US in these confrontations by the two Chinese "all-weather" allies, China is quietly getting its economical railway back on the tracks. It is still not the military power that it wants to be, and when it believes it can take on the mighty Americans, then the Chinese will use everything they have and come forward with major war intentions. Until then, it will be the North Korea and the other nation to play the Americans, and keep them guessing. China has lost time in their recent economic down-slide, and the other factor that will depress their plans is -- Trump.
If Trump eventually becomes the President of the USA, then Chinese expansion plans will take a major hit, simply because Trump can take lightning fast and completely unorthodox actions, and he can upset all the Chinese plans. I believe that only Trump, in the entire world, has the ability to counter these three nations, and ISIS as well in a successful way. Trump will have the entire nation behind him if there is another small or big unfortunate event in the USA, and China cannot afford to let that happen imho. President trump can up with the ultimate spanner in the work for Chinese plans.
Also, in case the US opens a huge front against China, then these two "all weather allies" that are unfortunately rouge nuclear-capable states, can become the urgent front-liners to keep up the nuisance value, and get itself some very precious time. If Trump opens a serious front against China, not necessarily a war like situation, then these two rouge states can always carry on doing what they do the best -- blackmailing USA and confrontations, and keep the tensions high in the NATO world.
I think that Russia can still play the major power that will stop both those rouge states in check. But to make that happens, the US must change its policies against Russia. A strong anti-China Russia can make the North Korea very quiet, because Russia in the top position over China will enable the surrounding nations and the NATO forces to checkmate the North Korean bluffs. They are definitely bluffs, because the North Korean leader will not let a NATO nuclear bomb fall on his head.... he is too materialistic, too power greedy, cunning to the core, and a hidden coward who still has the ability to understand what's good and whats devastating for him if US gets really angry. He will only keep stretching the rubber-band to see how much he can do it without risking his own life -- either in death or in prison, or being thrown in front of his own thousand plus blood-thirsty dogs by his stretched out generals.
He must keep saying those terror speeches to keep his cruel image on top of his own people. With a nuclear war, he might kill a million people, but his own survival will be impossible. He won't therefore risk a war of that magnitude which only one party will will outright, and that party is definitely not North Korea. In case of a war with South Korea, the ultimate loser will be China in the field of economics and trade.
Would China risk that situation to happen? It will not only lose one of its cunning all-weather friend forever, it will also put China's trade a million years back because of the global retaliation. So, imho, China will not let a single North Korean nuclear bomb to leave that country's shores, at least for the next 10 years or so, and if Trump becomes the President, then all those barking leaders will have to get back into their caves for hibernation.
All these may be off by a long shot, but I like to think this way... keeps my blood pressure in limits by this line of thought!