OSDev.org

The Place to Start for Operating System Developers
It is currently Mon Mar 18, 2024 11:23 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: [TCP] My OS acked the packet but windows is still sending
PostPosted: Sat Jan 14, 2023 2:52 pm 
Offline
Member
Member

Joined: Tue Aug 17, 2021 10:40 am
Posts: 104
Location: CN
Image
What should tell Windows not to send more?
Here is my code to handle "Established"
Code:
                        case TCPStatus.Established:
                        {
                            if (tcp_hdr->Flags.HasFlag(TCPFlags.TCP_ACK))
                            {
                                if(client.SndUna < tcp_hdr->Ack && tcp_hdr->Ack <= client.SndNxt)
                                {
                                    client.SndUna = tcp_hdr->Ack;
                                    if(client.SndWl1<tcp_hdr->Seq || (client.SndWl1 == tcp_hdr->Seq && client.SndWl2 <= tcp_hdr->Ack))
                                    {
                                        client.SndWnd = tcp_hdr->WindowSize;
                                        client.SndWl1 = tcp_hdr->Seq;
                                        client.SndWl2 = tcp_hdr->Ack;
                                    }
                                }
                                if(tcp_hdr->Ack < client.SndUna)
                                {
                                    return;
                                }
                                if(tcp_hdr->Ack > client.SndNxt)
                                {
                                    TCPSend(client, client.SndNxt, TCPFlags.TCP_ACK, null, 0);
                                }
                                if (tcp_hdr->Flags.HasFlag(TCPFlags.TCP_PSH))
                                {
                                    client.OnData(buffer, length);
                                    client.RcvNxt += (uint)length;
                                    TCPSend(client, client.SndNxt, TCPFlags.TCP_ACK, null, 0);
                                }else if (tcp_hdr->Flags.HasFlag(TCPFlags.TCP_FIN))
                                {
                                    client.RcvNxt++;
                                    TCPSend(client, client.SndNxt, TCPFlags.TCP_ACK, null, 0);
                                    client.Status = TCPStatus.TimeWait;
                                    client.Status = TCPStatus.Closed;
                                }
                                if(length > 0 && tcp_hdr->Seq >= client.RcvNxt)
                                {
                                    client.OnData(buffer, length);
                                    client.RcvNxt += (uint)length;
                                }
                            }
                            if (tcp_hdr->Flags.HasFlag(TCPFlags.TCP_RST))
                            {
                                client.Status = TCPStatus.Closed;
                            }else if (tcp_hdr->Flags.HasFlag(TCPFlags.TCP_FIN))
                            {
                                client.RcvNxt++;
                                TCPSend(client, client.SndNxt, TCPFlags.TCP_ACK, null, 0);
                                client.Status = TCPStatus.CloseWait;
                                TCPSend(client, client.SndNxt, TCPFlags.TCP_FIN, null, 0);
                                client.Status = TCPStatus.LastAcknowledge;
                            }
                        }
                        break;

_________________
My github: https://github.com/nifanfa


Top
 Profile  
 
 Post subject: Re: [TCP] My OS acked the packet but windows is still sendin
PostPosted: Sat Jan 14, 2023 3:02 pm 
Offline
Member
Member

Joined: Tue Aug 17, 2021 10:40 am
Posts: 104
Location: CN
Image
I think the seq and ack is in the right value. but why windows is still resending the packet?

_________________
My github: https://github.com/nifanfa


Top
 Profile  
 
 Post subject: Re: [TCP] My OS acked the packet but windows is still sendin
PostPosted: Sat Jan 14, 2023 3:16 pm 
Offline
Member
Member

Joined: Tue Aug 17, 2021 10:40 am
Posts: 104
Location: CN
Image

_________________
My github: https://github.com/nifanfa


Top
 Profile  
 
 Post subject: Re: [TCP] My OS acked the packet but windows is still sendin
PostPosted: Sat Jan 14, 2023 3:38 pm 
Offline
Member
Member

Joined: Tue Aug 17, 2021 10:40 am
Posts: 104
Location: CN
This is the whole process:
Image

_________________
My github: https://github.com/nifanfa


Top
 Profile  
 
 Post subject: Re: [TCP] My OS acked the packet but windows is still sendin
PostPosted: Sat Jan 14, 2023 3:43 pm 
Offline
Member
Member

Joined: Sat Mar 10, 2018 10:16 am
Posts: 296
well I am not sure what is this connection supposed to do, but it seems like you are not responding to request in PSH ACK packet, you just ancknowledge it with length 0, so windows is trying to get some answer from you.

_________________
https://github.com/VendelinSlezak/BleskOS


Top
 Profile  
 
 Post subject: Re: [TCP] My OS acked the packet but windows is still sendin
PostPosted: Sat Jan 14, 2023 3:46 pm 
Offline
Member
Member

Joined: Tue Aug 17, 2021 10:40 am
Posts: 104
Location: CN
Klakap wrote:
well I am not sure what is this connection supposed to do, but it seems like you are not responding to request in PSH ACK packet, you just ancknowledge it with length 0, so windows is trying to get some answer from you.

So all i have to do is send the same packet to windows with PSH ACK flags?

_________________
My github: https://github.com/nifanfa


Top
 Profile  
 
 Post subject: Re: [TCP] My OS acked the packet but windows is still sendin
PostPosted: Sat Jan 14, 2023 3:48 pm 
Offline
Member
Member

Joined: Sat Mar 10, 2018 10:16 am
Posts: 296
no, just to clarify subject, what IP address are you in this connection?

_________________
https://github.com/VendelinSlezak/BleskOS


Top
 Profile  
 
 Post subject: Re: [TCP] My OS acked the packet but windows is still sendin
PostPosted: Sat Jan 14, 2023 3:51 pm 
Offline
Member
Member

Joined: Tue Aug 17, 2021 10:40 am
Posts: 104
Location: CN
Klakap wrote:
no, just to clarify subject, what IP address are you in this connection?

The IP address is the IP address of the vmware virtual NIC, I'm using host-only mode, I set up a tcp server on windows so my OS can connect to it

_________________
My github: https://github.com/nifanfa


Top
 Profile  
 
 Post subject: Re: [TCP] My OS acked the packet but windows is still sendin
PostPosted: Sat Jan 14, 2023 3:53 pm 
Offline
Member
Member

Joined: Sat Mar 10, 2018 10:16 am
Posts: 296
so you are 192.168.81.20?

_________________
https://github.com/VendelinSlezak/BleskOS


Top
 Profile  
 
 Post subject: Re: [TCP] My OS acked the packet but windows is still sendin
PostPosted: Sat Jan 14, 2023 3:55 pm 
Offline
Member
Member

Joined: Tue Aug 17, 2021 10:40 am
Posts: 104
Location: CN
Klakap wrote:
so you are 192.168.81.20?

Yes. But I just picked one randomly because all you have to do is answer the windows saying the ip is yours and tell your mac address using arp procotol

_________________
My github: https://github.com/nifanfa


Top
 Profile  
 
 Post subject: Re: [TCP] My OS acked the packet but windows is still sendin
PostPosted: Sat Jan 14, 2023 3:56 pm 
Offline
Member
Member

Joined: Tue Aug 17, 2021 10:40 am
Posts: 104
Location: CN
Klakap wrote:
so you are 192.168.81.20?

as you can see from the wireshark screenshot. it just worked but windows just resending the same packet

_________________
My github: https://github.com/nifanfa


Top
 Profile  
 
 Post subject: Re: [TCP] My OS acked the packet but windows is still sendin
PostPosted: Sat Jan 14, 2023 3:59 pm 
Offline
Member
Member

Joined: Sat Mar 10, 2018 10:16 am
Posts: 296
okay, so you successfully estabilished connection, but after that, windows send you PSH ACK packet with data length 3. what is in this packet?

_________________
https://github.com/VendelinSlezak/BleskOS


Top
 Profile  
 
 Post subject: Re: [TCP] My OS acked the packet but windows is still sendin
PostPosted: Sat Jan 14, 2023 4:00 pm 
Offline
Member
Member

Joined: Tue Aug 17, 2021 10:40 am
Posts: 104
Location: CN
Klakap wrote:
well I am not sure what is this connection supposed to do, but it seems like you are not responding to request in PSH ACK packet, you just ancknowledge it with length 0, so windows is trying to get some answer from you.

Image
I just tried to use TCP to communicate between 2 windows PCs and i think the way i respose is right...
it also just replied it with length 0 ancknowledge

_________________
My github: https://github.com/nifanfa


Top
 Profile  
 
 Post subject: Re: [TCP] My OS acked the packet but windows is still sendin
PostPosted: Sat Jan 14, 2023 4:01 pm 
Offline
Member
Member

Joined: Tue Aug 17, 2021 10:40 am
Posts: 104
Location: CN
Klakap wrote:
okay, so you successfully estabilished connection, but after that, windows send you PSH ACK packet with data length 3. what is in this packet?

just random text to make sure my OS can receive the text

_________________
My github: https://github.com/nifanfa


Top
 Profile  
 
 Post subject: Re: [TCP] My OS acked the packet but windows is still sendin
PostPosted: Sat Jan 14, 2023 4:06 pm 
Offline
Member
Member

Joined: Sat Mar 10, 2018 10:16 am
Posts: 296
I see that you use same source and destination port. I am not TCP expert, but it seems wrong to me. I think you should use different port for you and different port for server.

_________________
https://github.com/VendelinSlezak/BleskOS


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: YaCy [Bot] and 14 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group