Solved

Packet Transfering at Datalink Layer

Posted on 2004-04-21
9
285 Views
Last Modified: 2010-04-22
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?
0
Comment
Question by:krkc
  • 3
  • 2
  • 2
9 Comments
 
LVL 45

Expert Comment

by:sunnycoder
Comment Utility
Hi krkc,

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
0
 

Author Comment

by:krkc
Comment Utility
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.
0
 
LVL 45

Accepted Solution

by:
sunnycoder earned 25 total points
Comment Utility
You are not supposed to know that at L2 !!! This has to be determined by the higher layers ... that is the whole point of layering

Still if you insist then determining this at L2 will require moving a good amount of code from higher layers to L2
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:krkc
Comment Utility
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.
0
 
LVL 1

Expert Comment

by:kevinnguyen
Comment Utility
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

0
 

Author Comment

by:krkc
Comment Utility
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,&myaddrlen);

//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(newbuf),0,(struct sockaddr*)&addr,sizeof(addr));

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.
0
 
LVL 1

Assisted Solution

by:kevinnguyen
kevinnguyen earned 25 total points
Comment Utility
I assume the following:

1) There are at least two computers on each LAN which they are connected together using a HUB. 2) With a HUB on each LAN, all computers on the same LAN will see each other's packets

Here are a few of my thoughts:

1) MyApp1 running on Router1 changes MAC address of outgoing packets originating from computer A on LAN A and forwards these packets to LAN B.
    a) What does MyApp1 do to packets receiving from LAN B ?
    b) Does MyApp1 append MAC address to those packets based on their destination IP address ?

2) The same issue applies to MyApp2

IMPORTANT:

a) Two routers exchange packets using source and destination IP address in IP header of packets.
When a packet on Router1 is forwared to Router2, its MAC address will be stripped off. Whether you changes packet's MAC address or not, Router2 will not receive packet with MAC address upon receiving it.

b) Only HUB and SWITCH uses MAC address inside packets to deliver packets to appropriate recipients on the same LAN. They don't go by source and destination IP address.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now