Download presentation
Presentation is loading. Please wait.
1
What to do in muxHandler()?
2
Get the headers Use function MinetReceive to get the packet p. Get the TCPHeader and IPHeader of p. You can use the function in class Packet. For example, FindHeader function. You can get the Tcpheader by using p.FindHeader(Headers::TCPHeader);
3
Find the connections Extract information from the IPHeaders and TCPHeaders. For example, src ip & port and dest ip &port. For example, using iph.GetDestIP function.(suppose iph is the ip header) Use the information above to find the connection the packet belongs in Clist. Clist is used for keeping all connections built. For example, using ConnectionList ::iterator cs = clist.FindMatching(c);// Specify c with src & dest information
4
Parse tcp header Get the state of current connection. You may need to modify it based on the packet received. For example, using (*cs).state.GetState(); Get the flags of TCP header, using tcph.GetFlags(f). Then check whether it is SYN, ACK, FIN.. And do corresponding action based on current state.
6
For Example if( IS_ACK(f) && IS_SYN(f) ) { cout<<"SYN ACK packet Received. will have to send ACK packet"<<endl; p.Print(cout); if( state == SYN_SENT ) { connstate.state.SetState(ESTABLISHED); unsigned int newack,last_recvd; tcph.GetAckNum(newack); tcph.GetSeqNum(last_recvd); connstate.state.SetLastAcked( newack ); connstate.state.SetLastRecvd( last_recvd ); connstate.timeout=Time() + ACK_TIMEOUT; char *data1 = "ACTIVE:in active connection\n"; Buffer b(data1,strlen(data1)); Packet psh; unsigned int old_time; TCPOptions opt; tcph.GetOptions(opt); old_time = ntohl(*(int *)(opt.data+8)); craftSynPacket(&psh,connstate,PSH_ACK_HEADER,0,old_time); psh.Print(cout); MinetSend(mux,psh); connstate.state.SetLastSent(connstate.state.GetLastSent()); status=STATUS; MinetSend(sock,write); }
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.