krkc
asked on
Packet Transfering at Datalink Layer
Hello Everyone, This is my first post.
Iam doing a new project which will transfer the data from one LAN to another LAN. These LAN's are connected by using routers(Linux Machines).
Iam capturing the packets at Datalink Layer of Router1, and Iam modifing the MAC ID's of the Packet and retransferring to the other Router2. From Router2 the packet will be send to the Corresponding LAN2 Machine. A Reply will be send back by the Router2 to Router1 which again will be send as acknowledgement to the LAN1 Machine.
The Problem is that Iam able to get only few acknowledgements, as for every 100 packets send Iam getting reply for only 40 packets. And for remaining Iam getting "Request Timmed Out".
How can i get 100% reply. What kind of socket options i have to use?
Iam doing a new project which will transfer the data from one LAN to another LAN. These LAN's are connected by using routers(Linux Machines).
Iam capturing the packets at Datalink Layer of Router1, and Iam modifing the MAC ID's of the Packet and retransferring to the other Router2. From Router2 the packet will be send to the Corresponding LAN2 Machine. A Reply will be send back by the Router2 to Router1 which again will be send as acknowledgement to the LAN1 Machine.
The Problem is that Iam able to get only few acknowledgements, as for every 100 packets send Iam getting reply for only 40 packets. And for remaining Iam getting "Request Timmed Out".
How can i get 100% reply. What kind of socket options i have to use?
ASKER
ya i do accept that several protocols send an ACK for n packets. But at Datalink layer how can i make sure that the packet which was received was an ACK packet or DATA Packet?
Iam using a Raw Socket to connect to the ethernet card. And using the SendTo option to send the packet.
Can you give me any kind of Example.
Iam using a Raw Socket to connect to the ethernet card. And using the SendTo option to send the packet.
Can you give me any kind of Example.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I think you have not understood my actual problem. Here iam giving the exact senario of my project.
LanA -> Gateway1 -> Router1 -> Router2 -> Gateway2 -> LanB
LanB -> Gateway2 -> Router2 -> Router1 -> Gateway1 -> LanA
When i ping from LanA to LanB then my ping request first goes to Gateway1, from there it goes to Router1, there my application will receive the packet and sends to the Router2. From Router2 again my application will receive the packet and sends to Gateway2. And finally Gateway2 will automatically sends the packet to the exact destination of LanB. Where again LanB will send ACK to Gateway2 -> Router2 ->MyApp2-> Router1 ->MyApp1-> Gateway1-> LanA.
Now i think you got my query. My application will sit in Router1 and Router2 doing the transmitting job.
Here iam facing some problems getting the ACK for all the ping requests i made.
LanA -> Gateway1 -> Router1 -> Router2 -> Gateway2 -> LanB
LanB -> Gateway2 -> Router2 -> Router1 -> Gateway1 -> LanA
When i ping from LanA to LanB then my ping request first goes to Gateway1, from there it goes to Router1, there my application will receive the packet and sends to the Router2. From Router2 again my application will receive the packet and sends to Gateway2. And finally Gateway2 will automatically sends the packet to the exact destination of LanB. Where again LanB will send ACK to Gateway2 -> Router2 ->MyApp2-> Router1 ->MyApp1-> Gateway1-> LanA.
Now i think you got my query. My application will sit in Router1 and Router2 doing the transmitting job.
Here iam facing some problems getting the ACK for all the ping requests i made.
One of reasons for "Requested timeout" message could be that both MyApp1 and MyApp2 running on Router1 and Router 2 respectively add a time delay to DATA and ACK packets sent to/from LanA and LanB.
Try to increase performance of MyApp1 and MyApp2. A lot of I/O operations to STDOUT may cause some time delays because they are time-consuming.
Good Luck !
kevinnguyen
Try to increase performance of MyApp1 and MyApp2. A lot of I/O operations to STDOUT may cause some time delays because they are time-consuming.
Good Luck !
kevinnguyen
ASKER
Iam not using the STDOUT or printf Statements.
My Applications job is just to receive the data and send it to another Network Interface Card.
Iam receving the Packet as
bufsize = recvfrom(sock,buff,1514,0( struct sockaddr*)&myaddr,&myaddrl en);
//Modify the MAC Addresses
newbuf[0]=0x00;
newbuf[1]=0x80;
newbuf[2]=0x48;
newbuf[3]=0x24;
newbuf[4]=0xE3;
newbuf[5]=0x9D;
newbuf[6]=0x00;
newbuf[7]=0x80;
newbuf[8]=0x48;
newbuf[9]=0x1E;
newbuf[10]=0x3A;
newbuf[11]=0x7E;
//Send to the Other NIC
snd=sendto(rmtHost,newbuf, sizeof(new buf),0,(st ruct sockaddr*)&addr,sizeof(add r));
This is all my app. does.
so no storing of buffer, no printf statements and GUI. Just transfer from one NIC to another NIC. My code is giving me only 20% replies with i ping from Lan A to Lan B.
My Applications job is just to receive the data and send it to another Network Interface Card.
Iam receving the Packet as
bufsize = recvfrom(sock,buff,1514,0(
//Modify the MAC Addresses
newbuf[0]=0x00;
newbuf[1]=0x80;
newbuf[2]=0x48;
newbuf[3]=0x24;
newbuf[4]=0xE3;
newbuf[5]=0x9D;
newbuf[6]=0x00;
newbuf[7]=0x80;
newbuf[8]=0x48;
newbuf[9]=0x1E;
newbuf[10]=0x3A;
newbuf[11]=0x7E;
//Send to the Other NIC
snd=sendto(rmtHost,newbuf,
This is all my app. does.
so no storing of buffer, no printf statements and GUI. Just transfer from one NIC to another NIC. My code is giving me only 20% replies with i ping from Lan A to Lan B.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I am not sure if this is your problem but it is a very probable cause ... Several protocols send an ACK for n packets and not every packet ... n depends on how many packets they can get in a reasonable time frame which will not cause a retransmit ... so it is more time dependent and not number of packets dependent ... Also if communication is two way, ACKs are often piggybacked on the data packets
Sunnycoder