Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

[MBS] Network Usage Level (MBS Xojo Plugin Mailinglist archive)

Back to the thread list
Previous thread: [MBS] Mailing list archive updated
Next thread: [MBS] 4.0dr1


Re: [MBS] MIDI Destinations and External Devices   -   Ron Benditt
  [MBS] Network Usage Level   -   Charlie Boisseau
   Re: [MBS] Network Usage Level   -   Christian Schmitz
    Re: [MBS] Network Usage Level   -   Charlie Boisseau
     Re: [MBS] Network Usage Level   -   Christian Schmitz
      Re: [MBS] Network Usage Level   -   Charlie Boisseau
       Re: [MBS] Network Usage Level   -   Christian Schmitz
        Re: [MBS] Network Usage Level   -   Charlie Boisseau
         Re: [MBS] Network Usage Level   -   Christian Schmitz
          Re: [MBS] Network Usage Level   -   Charlie Boisseau
           Re: [MBS] Network Usage Level   -   Christian Schmitz
            Re: [MBS] Network Usage Level   -   Charlie Boisseau
             Re: [MBS] Network Usage Level   -   Christian Schmitz
          Re: [MBS] Network Usage Level   -   Charlie Boisseau
           Re: [MBS] Network Usage Level   -   Christian Schmitz
            Re: [MBS] Network Usage Level   -   Charlie Boisseau
             Re: [MBS] Network Usage Level   -   Christian Schmitz
             [MBS] BundleResourceFolderItemMBS   -   Stefan Fuerst
   Re: [MBS] Network Usage Level   -   Christian Schmitz
    Re: [MBS] Network Usage Level   -   Charlie Boisseau
     Re: [MBS] Network Usage Level   -   Christian Schmitz

[MBS] Network Usage Level
Date: 01.01.04 23:20 (Thu, 01 Jan 2004 22:20:38 +0000)
From: Charlie Boisseau
Christian,

Is there any class in the MBS plugin which will allow me to get a live
reading of the current network throughput. I want to have a network monitor
in my app which gives the user a network usage level.

If not, I imagine it would best work if you created a class called something
like 'NetUsageMBS' which has a 'Start (Interface As Integer)' function.
This starts counting the amount of bytes coming in and out and pits the
values into properties called something like 'TrafficIn' and 'TrafficOut'.
A 'stop' function would stop the counting.

Is this possible?

Cheers.

Re: [MBS] Network Usage Level
Date: 02.01.04 02:41 (Fri, 2 Jan 2004 02:41:30 +0100)
From: Christian Schmitz
Charlie Boisseau <<email address removed>> wrote:

> Christian,
>
> Is there any class in the MBS plugin which will allow me to get a live
> reading of the current network throughput. I want to have a network monitor
> in my app which gives the user a network usage level.

I found functions which I added to 4.0dr2 which count the read&write
bytes for the disc drives.

But if the only way to get the network counters is the one showed in
top.c (kernel memory read), we need root access. And whenever we need
root access, you should write a helping shell application yourself.
(based on top.c)

Mfg
Christian

Re: [MBS] Network Usage Level
Date: 02.01.04 11:37 (Fri, 02 Jan 2004 10:37:45 +0000)
From: Charlie Boisseau
> I found functions which I added to 4.0dr2 which count the read&write
> bytes for the disc drives.

That sounds useful - what are these functions called?

> But if the only way to get the network counters is the one showed in
> top.c (kernel memory read), we need root access. And whenever we need
> root access, you should write a helping shell application yourself.
> (based on top.c)

I think there must be another way - I know of several apps which do it
without asking for a password. iPulse does it, for example.

Where can I find top.c? I want to see what sort of functions are available,
but I can't seem to find the c file.

Cheers.

Re: [MBS] Network Usage Level
Date: 02.01.04 13:06 (Fri, 2 Jan 2004 13:06:50 +0100)
From: Christian Schmitz
Charlie Boisseau <<email address removed>> wrote:

> > I found functions which I added to 4.0dr2 which count the read&write
> > bytes for the disc drives.
>
> That sounds useful - what are these functions called?

DarwinDriveStatisticsMBS class.

> I think there must be another way - I know of several apps which do it
> without asking for a password. iPulse does it, for example.

Than ask how they do it.
Maybe they call a shell application on your Mac which has already set
the Run-As-Root bit.

> Where can I find top.c?

At Apple.com in the sources of Darwin.
I forgot the exact location.

Mfg
Christian

Re: [MBS] Network Usage Level
Date: 02.01.04 19:11 (Fri, 02 Jan 2004 18:11:00 +0000)
From: Charlie Boisseau
Christian,

I have been reading up on the Darwin classes for networking and IO. It
would seem that using the IONetwork classes one can retrieve stats on a
particular network interface.

>From what I have read this seems to be the layout of the relevant functions:

The IONetworkInterface class (defined in IONetworkInterface.h) represents a
referenced network interface - you may already have used this for the
NetworkInterfaceMBS class?

IONetworkStats is a data structure (defined in IONetworkStats.h) which holds
the following information: inputPackets, inputErrors, outputPackets,
outputErrors and collisions. From the documentation, this sounds like the
exact info I want.

According to the ADC docs, the IONetworkInterface class has a function
called 'getNetworkData(aKey)' where aKey would be in this case
'kIONetworkStatsKey'; the constant for getting an IONetworkStats structure
in return.

I'm no pro with C, but here's what I'm getting at:

IONetworkStats getInterfaceStats (IONetworkInterface myInterface) {

//This function assumes you already have an initialised
//IONetworkInterface instance which you pass as the parameter.

//Create an instance of IONetworkStats to contain the stats:

IONetworkStats myStats;

//Now populate myStats with the current data from the referenced
//network interface 'myInterface'

myStats = myInterface->getNetworkData(kIONetworkStatsKey);

//Return the object with the values:

return myStats;
}

If you could implement something, even in an abstract form, just so I can
access these properties, that would be ideal.

Cheers.

Re: [MBS] Network Usage Level
Date: 04.01.04 17:21 (Sun, 4 Jan 2004 17:21:28 +0100)
From: Christian Schmitz
Charlie Boisseau <<email address removed>> wrote:

> Christian,
>
> The IONetworkInterface class (defined in IONetworkInterface.h) represents a
> referenced network interface - you may already have used this for the
> NetworkInterfaceMBS class?

Yes. Done.
It's nearly the same as the disc statistics class.

> myStats = myInterface->getNetworkData(kIONetworkStatsKey);

That's the big problem.
Codewarrior C++ virtual functions are not compatibel to the ones from
gcc. I can't call that, but I can ask it for the CFProperties.

Mfg
Christian

Re: [MBS] Network Usage Level
Date: 04.01.04 20:30 (Sun, 04 Jan 2004 19:30:26 +0000)
From: Charlie Boisseau
Christian,

>> myStats = myInterface->getNetworkData(kIONetworkStatsKey);
>
> That's the big problem.
> Codewarrior C++ virtual functions are not compatibel to the ones from
> gcc. I can't call that, but I can ask it for the CFProperties.

So there's a workaround? Will you be able to put this in the next DR
release?

Cheers.

Re: [MBS] Network Usage Level
Date: 04.01.04 20:44 (Sun, 4 Jan 2004 20:44:29 +0100)
From: Christian Schmitz
Charlie Boisseau <<email address removed>> wrote:

> So there's a workaround? Will you be able to put this in the next DR
> release?

It's in 4.0dr2.

Mfg
Christian

Re: [MBS] Network Usage Level
Date: 04.01.04 21:24 (Sun, 04 Jan 2004 20:24:34 +0000)
From: Charlie Boisseau
>> So there's a workaround? Will you be able to put this in the next DR
>> release?
>
> It's in 4.0dr2.

Ah yes - I see it. Fantastic. I don't suppose you know of a way to get
byte counts like in Apple's Activity Monitor app? That would be ideal.

Cheers,

Re: [MBS] Network Usage Level
Date: 04.01.04 21:40 (Sun, 4 Jan 2004 21:40:33 +0100)
From: Christian Schmitz
Charlie Boisseau <<email address removed>> wrote:

> Ah yes - I see it. Fantastic. I don't suppose you know of a way to get
> byte counts like in Apple's Activity Monitor app? That would be ideal.

I don't know a way where I can get them without root rights.

mfg
Christian

Re: [MBS] Network Usage Level
Date: 04.01.04 21:47 (Sun, 04 Jan 2004 20:47:38 +0000)
From: Charlie Boisseau
Christian,

> I don't know a way where I can get them without root rights.

Do you think there's a way of asking Apple? Activity monitor doesn't use
root rights, but it does run a helper tool called 'pmTool', but I don't
think that does it.

Cheers.

Re: [MBS] Network Usage Level
Date: 05.01.04 00:10 (Mon, 5 Jan 2004 00:10:51 +0100)
From: Christian Schmitz
Charlie Boisseau <<email address removed>> wrote:

> Christian,
>
> > I don't know a way where I can get them without root rights.
>
> Do you think there's a way of asking Apple?

I'll ask on the darwin-development list.

Mfg
Christian

Re: [MBS] Network Usage Level
Date: 04.01.04 22:52 (Sun, 04 Jan 2004 21:52:57 +0000)
From: Charlie Boisseau
Christian,

> It's in 4.0dr2.

I was wondering if you could implement the getNetworkData(aKey) function.
It would mean that the constants could be used to get values. You have
already added the constants.

Cheers.

Re: [MBS] Network Usage Level
Date: 05.01.04 00:13 (Mon, 5 Jan 2004 00:13:49 +0100)
From: Christian Schmitz
Charlie Boisseau <<email address removed>> wrote:

> Christian,
>
> > It's in 4.0dr2.
>
> I was wondering if you could implement the getNetworkData(aKey) function.
> It would mean that the constants could be used to get values. You have
> already added the constants.

Please check the example.
What does getNetworkData give you what the CFDictionary from the plugin
doesn't contain?

Mfg
Christian

Re: [MBS] Network Usage Level
Date: 05.01.04 00:22 (Sun, 04 Jan 2004 23:22:27 +0000)
From: Charlie Boisseau
Christian,

> Please check the example.
> What does getNetworkData give you what the CFDictionary from the plugin
> doesn't contain?

  kIOInterfaceExtraFlags
  kIOInterfaceFlags
  kIOInterfaceNamePrefix
  kIOInterfaceState
  kIOInterfaceType
  kIOInterfaceUnit
  kIOMaxTransferUnit
  kIOMediaAddressLength
  kIOMediaHeaderLength
  kIONetworkData
  kIONetworkInterfaceClass
  kIOPrimaryInterface

There are also the following functions:

Public
  addNetworkData
  attachToDataLinkLayer
  clearInputQueue
  detachFromDataLinkLayer
  flushInputQueue
  getController
  getExtraFlags
  getFlags
  getInterfaceState
  getInterfaceType
  getMaxTransferUnit
  getMediaAddressLength
  getMediaHeaderLength
  getNamePrefix
  getNetworkData(aKey)
  getNetworkData(aKey)
  getUnitNumber
  init
  inputEvent
  inputPacket
  isPrimaryInterface
  isRegistered
  matchPropertyTable
  registerOutputHandler
  removeNetworkData(aKey)
  removeNetworkData(aKey)
  setProperties

Protected
  controllerDidChangePowerState
  controllerDidOpen
  controllerWillChangePowerState
  controllerWillClose
  free
  getIfnet
  handleClientClose
  handleClientOpen
  handleClose
  handleIsOpen
  handleOpen
  initIfnet
  lock
  newUserClient
  performCommand
  powerStateDidChangeTo
  powerStateWillChangeTo
  setExtraFlags
  setFlags
  setInterfaceState
  setInterfaceType
  setMaxTransferUnit
  setMediaAddressLength
  setMediaHeaderLength
  setUnitNumber
  unlock

Cheers.

--
Charlie Boisseau


--
Web8REALbasic mailing list
<email address removed>
http://mail.huynh.de/mailman/listinfo/web8realbasic

Re: [MBS] Network Usage Level
Date: 05.01.04 20:04 (Mon, 5 Jan 2004 20:04:55 +0100)
From: Christian Schmitz
Charlie Boisseau <<email address removed>> wrote:

> kIOInterfaceExtraFlags
> kIOInterfaceFlags
> kIOInterfaceNamePrefix
> kIOInterfaceState
> kIOInterfaceType
> kIOInterfaceUnit
> kIOMaxTransferUnit
> kIOMediaAddressLength
> kIOMediaHeaderLength
> kIONetworkData
> kIONetworkInterfaceClass
> kIOPrimaryInterface

This contants can be used with the dictionary already.
Just check what's inside using the CFShowMBS command.

> There are also the following functions:
>
> Public
> Protected

It's impossible to call them as we are in the wrong environment.
You need to make your own shell application to give you this values.

Mfg
Christian

Re: [MBS] Network Usage Level
Date: 14.01.04 23:00 (Wed, 14 Jan 2004 23:00:13 +0100)
From: Christian Schmitz
Charlie Boisseau <<email address removed>> wrote:

> Christian,
>
> Is there any class in the MBS plugin which will allow me to get a live
> reading of the current network throughput.

I got code to do this in a shell application without root rights.

Bytes and packets sent. For all interfaces individually.
But it may not be easy to add it and I'm currently quite busy with ATS
and WebKit.

Mfg
Christian

Re: [MBS] Network Usage Level
Date: 14.01.04 23:39 (Wed, 14 Jan 2004 22:39:05 +0000)
From: Charlie Boisseau
Christian,

> Bytes and packets sent. For all interfaces individually.
> But it may not be easy to add it and I'm currently quite busy with ATS
> and WebKit.

Fantastic - can you send me the source of the helper tool? Or even the
binary? That would be great. If you can integrate it into MBS, that would
be ideal. How did you do it? Did you use the SystemConfiguration
framework? I heard you can get the info from there?

Thanks a lot.

Re: [MBS] Network Usage Level
Date: 15.01.04 00:02 (Thu, 15 Jan 2004 00:02:42 +0100)
From: Christian Schmitz
Charlie Boisseau <<email address removed>> wrote:

> Christian,
>
> > Bytes and packets sent. For all interfaces individually.
> > But it may not be easy to add it and I'm currently quite busy with ATS
> > and WebKit.
>
> Fantastic - can you send me the source of the helper tool?
> Or even the binary?

It's ifstat.
Write me offlist if you need my source. The source you may find on some
website may be newer and already support the darwin changes needed.

> That would be great. If you can integrate it into MBS, that would
> be ideal. How did you do it?

I asked some clever people ;-)
It should be possible to include it, but stuff like this is a lot of
work and unless there is a big demand or someone pays, I'd prefer not to
do this work.

> Did you use the SystemConfiguration framework?

no. it's sysctl.

Mfg
Christian