Priyanka Mishra
Priyanka Mishra

Reputation: 10728

Need of Formula for Accurate Bandwith for 1 Gigabit NIC Card

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];

Upvotes: 2

Views: 445

Answers (4)

Harty
Harty

Reputation: 316

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.

Upvotes: 0

Will Dean
Will Dean

Reputation: 39520

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.

Upvotes: 1

Jared
Jared

Reputation: 39893

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.

Upvotes: 1

mat
mat

Reputation: 13363

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.

Upvotes: 1

Related Questions