Click here to Skip to main content
15,888,733 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello every one

I am try to make program that record video from HD camera and i make that already ( use web camera ).

My problem now with use ARQ protocol (STOP AND WAIT ) with packet lost, so how i can use this protocol in C# . i am using AFroge framwork.

http://e.top4top.net/p_462d081.png[^]

What I have tried:

I found this code in google but i do not know where i can use and how

C#
objselected_frame_stp_wt is the frame we selected from Transmitter listBox
dtimeout is our predetermined timeout
tsSend_Time is a timespan object calculated by a timer
objFrame and objAck are objects from class clssSqaure, responsible for creating and moving the primitives

code:

if (objselected_frame_stp_wt != null)
        {
            if (tsSend_Time.Seconds > dtimeout)//send time exceeded predetermined timeout
            {
                if (bsend_file) //Rx didn't receive Frame
                    lbl_receiver.Text = "Timeout";

                else            //Tx didn't receive Acknowledgment
                    lbl_sender.Text = "Timeout";

                timer1.Enabled = false;//stop sending
            }

            if (bsend_file)//Frame is being sent to Rx
            {
                if (LBx_Receiver.Items.Contains(objselected_frame_stp_wt))
                    lbl_sender.Text = "Resending " + objselected_frame_stp_wt.ToString();
                else
                    lbl_sender.Text = "Sending " + objselected_frame_stp_wt.ToString();

                if ((objFrame.Fxpos + dlen) > nwidth)//frame arrived to Rx
                {
                    if (!LBx_Receiver.Items.Contains(objselected_frame_stp_wt))
                    {
                        LBx_Receiver.Items.Add(objselected_frame_stp_wt);
                    }
                    lbl_sender.Text = "awaiting acknowledgement";
                    lbl_receiver.Text = "sending acknowledgement";
                    bsend_file = false;
                    dtstart = DateTime.Now;
                    objAck = new clssSqaure(nwidth, -20, -1, color_yellow);
                    lst_clssSqaure.Add(objAck);
                }
                objFrame.Fxpos += fspeed * objFrame.Fvec_X;
            }
            else//Ack is being sent to Tx
            {
                if (((objAck.Fxpos - dlen + 10) < (nwidth * -1)))//Ack arrived to Tx
                {
                    lbl_sender.Text = "Acknowledgement received";
                    if (LBx_Receiver.Items.Contains(objselected_frame_stp_wt))
                    {
                        LBx_Sender.Items.Remove(objselected_frame_stp_wt);
                    }
                    timer1.Enabled = false;
                    bsend_file = true;
                }
                objAck.Fxpos += fspeed * objAck.Fvec_X;
            }
        }       
Posted
Updated 16-Feb-16 8:55am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900