views:

309

answers:

4

I am Need of Formula to Accurately Calculate Bandwith for 1 Gig Nic Card. What i am doing is send Layer 2 Packets @ 1Gbps but my software is showing 6oo Mbps.

The whole experiment is Back to Back. No switch No Router.

Here is what i did.

// LinkSpeed = 1Gb

UINT nBandwidth =   LinkSpeed/100;//Mbps


nBandwidth = nBandwidth/8; //Bytes/sec

nBandwidth = nBandwidth/FrameLength;
//Frames/Sec. Frame Length = 1518

UINT FramesPerBurst = (nBandwidth*Sleeptime)/1000;
//Frames/Burst 

UINT nBufferSpaceNeededPerFrame = FrameLength-4 + sizeof(dump_bpf_hdr));


UINT nTxBufferSize = FramesPerBurst * nBufferSpaceNeededPerFrame;

unsigned char* pTxBuffer = new
unsigned char[m_nTxBufferSize];
+1  A: 

In ethernet, you also have to take into account the interframe gap, which is at minimum, 96 quantum time, that is, the quantum time being the time to send a bit, which is, 1ns in GigaEthernet (1 second / 1,000,000,000).

Also, if you get a collision, there will be backoff time, which quantum is chosen randomly between 0 and 2^<nb collisions> - 1.

mat
A minor point - you won't get a collision on Gigabit, because *all* real-world GigE systems are full-duplex.
Will Dean
@WillDean, what about when two unrelated stations try to transmit simultaneously? I don't know about GigE but, if it's just faster ethernet, then that's also a possible collision.
paxdiablo
Transmit simultaneous on which shared medium? mahesh uses a straight connection, and otherwise your GigE NIC connects to a port on a switch. In either case, there are no more than two full-duplex transmitters per cable segment.
MSalters
Not necessarily a switch. If they're all on a hub, they're basically sharing the same line, that's why promiscuous mode works on NICs to let them see all traffic. In that case, two can transmit at once, which is why ethernet has the back-off timers.
paxdiablo
+1  A: 

Just because your card is a 1 Gigabit card that doesn't mean you will get that entire speed. On top of what Mat said you have to worry about signal attenuation and interfearence. If the router or switch gets congested this will also slow down your transfer speed. No formula can give you a completely accurate number for real world data transfer rates.

Jared
+1  A: 

If you're really doing all those calculation using integers, you're going to be getting some strange results...

The hardware which talks to the cable will 99.999% certainly be capable of doing the full 125MBytes/second, and a lightly-loaded switch will probably keep up too. Unless you have a disaster, you won't be seeing any significant error rate on the wire, either.

Your real performance is most likely affected by the platform you're using to transmit the packets - you don't say much about that.

Will Dean
A: 

First, you need a "long" at a minimum to store the no. of frames you received.

To calculate the bandwidth being used,

a = GetIntfCounters()

Start a timer (timeout) in seconds

b = GetIntfCounters()

Pkts/sec = (b - a)/timeout

Bits/sec = (Pkts/sec * pktsize)

Bytes/sec = (Bits/sec)/8

The GetIntfCounters() would depend on the software platform that you are using. Instead of a timer, you can use a sleep for a given interval, and then calculate the pps over that interval. However, the only realistic calculation of bandwidth at which you device is receiving frames will be if you take interface counters into consideration.

Harty