The program receives "ACK" but is not able to read the whole packet at once without giving some delay in the code.
That is because serial data transmission is ssslllooowww. On any one iteration through loop, there will not necessarily be a while packet to read.
In the 1st loop it reads "A" then in the second loops "CK" to make the complete buffer.
That is what it is supposed to do.
That's why i have introduced some delay.
Wrong.
What shall i do to improve this?????
Develop some realistic expectations. Serial data transmission is slow. Expect that. There is NOTHING you can do to make it faster except increase the baud rate, up to the maximum supported.
I want to send Hello World then wait for ACK from remote device and calculate the time it takes for this process.
You are doing that. What difference does it make if you get A at 1:30, C and 2:15, and K at 4:30 versus getting ACK at 4:30?
Please assist me..........
I can't. The program is doing what you programmed it to do. That you do not understand how serial data transmission works and/or have unrealistic expectations is not something I can help you with.