• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: TCP connection count
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: TCP connection count


  • Subject: Re: TCP connection count
  • From: "Peter Sichel" <email@hidden>
  • Date: Mon, 15 Oct 2007 11:01:28 -0400

On 10/14/07, Eyal Redler wrote:

>
>> You can count TCP connections using Sysctl to get a list of
>> TCP connection control blocks using MIB name CTL_NET, AF_INET,
>> IPPROTO_TCP, TCPCTL_PCBLIST.  You can read more about this in
>> Steven's UNIX Network Programming.  I use this in the Connection
>> List tool in IPNetMonitorX.
>
>Thanks for the answer, Peter, I don't have Steven's book (I guess I
>should order it) and I'm having a little difficulty walking the data
>structure I'm getting back when calling sysctl using this mib name.
>Based on some source code I found over the net, I managed to figure
>out the following code but I'm pretty sure I need to filter some of
>the tcpcb's according to the xt_tp.t_state field, unfortunately, I
>have no idea what are the possible states. I'm also really not sure
>about the actual iteration, does this structure end with a dummy
>element?

No, I don't believe so.  The number of elements is based on the
size of the data returned.  A good way to understand each field
of the structure is to look at the Darwin sources that define
them.

First, you'll need to agree to Apple's Public Source License (APSL),
then download the "xnu" project (Darwin kernel), set your favorite
multi-file search tool such as BBEdit to search the bsd/net/
subdirectory, and then have at it.

You'll quickly discover the file tcp_var.h which contains the tcpcb
structure.  Then you can search for "t_state" to see what other code
uses it and what values are being set.

One of the killer features of Mac OS X networking from a developer
standpoint is that you can look at the sources to see what it's
actually doing.

I hope this helps.

- Peter


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >TCP connection count (From: Eyal Redler <email@hidden>)
 >Re: TCP connection count (From: "Peter Sichel" <email@hidden>)
 >Re: TCP connection count (From: Eyal Redler <email@hidden>)
 >Re: TCP connection count (From: "Peter Sichel" <email@hidden>)
 >Re: TCP connection count (From: Eyal Redler <email@hidden>)

  • Prev by Date: Re: TCP connection count
  • Next by Date: Inserting NAT for a local interface into the Firewall rules
  • Previous by thread: Re: TCP connection count
  • Next by thread: Inserting NAT for a local interface into the Firewall rules
  • Index(es):
    • Date
    • Thread