The effects of thermal and fuel stratification and turbulent transport on knocking formation are numerically modeled in the negative temperature coefficient (NTC) region using dimethyl ether/air mixtures with a detailed chemistry. The critical conditions of knocking formation with thermal and fuel concentration gradients are examined. The effects of turbulence timescales on knocking development and knocking strength are explored. The results show that either a thermal gradient, concentration gradient, or combine gradients can initiate knocking. A unified criterion and diagram for knocking formation including both thermal and fuel concentration gradients as well as the normalized length scale of gradient fields is demonstrated. The results show that turbulence transport can delay knocking/detonation transition and dramatically reduce detonation strength due to turbulent mixing. It is found that when turbulence timescale is much shorter than the ignition delay time of the gradient field, the knocking formation will be suppressed. The present research provides important insights of knocking formation and control of knocking using stratifications and turbulence in the real engines.