LoRaWAN Downlink Confirmed Data

I have a question about how to change the header of a LoRaWAN packet.

The upper 3 bits of "MHDR" in the packet header indicate the message type. If bit # 7, 6, 5 is set to "101", it will be "Downlink Confirmed Data".

I want to change the upper 3 bits of "MHDR" to "101" when sending downlink data via the route of MQTT-> Network server-> Gateway. How should I do?
Could you give me some advice?

Well this is Not the place for this question which is a deep #LoRaWAN protocol question.
Let's take a step back
Which LNS (LoRaWAN network server) are you using?

Normally the you would specify a confirmed msg via API
Changing the MHDR should mean you need to re-calculate the MIC.

Hi iiLaw-san,

Thank you for your advice.

I'm using open-source LoRaWAN Server.

Best regards

ok I had a look there doesn't seem to be an API example of a downlink.
Any reason you didn't look at at chirpstack this is a very widely used OS LNS stack and runs on constrained devices and server. Many LoRaWAN manufactures and network operators use it.

Sending a confirmed downlink is easy
https://www.chirpstack.io/application-server/integrations/mqtt/#scheduling-a-downlink