2004-06-09 13:48:24

by Andreas Gaufer

[permalink] [raw]
Subject: [Bluez-devel] hci_create_connection assuming timeout too soon

Hi,

I noticed that many tools that use hci_create_connection use a hard coded
timeout-value that varries between 1000 and 25000. 1000 is much to short for
most mobile phones.

This leads to error messages even if the chip didnt report a "connection
complete" yet. Very often a conection complete with 00 is reported
later but the tool did exit already.

IMHO we could rely on the chips page timeout and wait for its "connection
complete" event. This timeout can also be changed with hciconfig pageto
by the user.

To catch a condition where the chip is stalled in some way i think the best
approach would be to time out on host side after the chips
page time out * 1,5 or so.

I changed hcitool to make it possible to specifiy the host side
timeout via command line but i dont belive that this is a good aproach because
it only fixes the symthoms not the root of the problem. Anyways I attach the
patch against the latest CVS-HEAD to show what im talking about.

In the moment my time is extremly short, i will try to bring up some code
that realy helps here later. Since im not that familiar with C please let me
know if somethings not right with my changes.

Greetings

Andreas Gaufer


Attachments:
hcitool.c.diff (3.51 kB)

2004-06-14 16:23:35

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [Bluez-devel] hci_create_connection assuming timeout too soon

Hi Steven,

> There are two potentially large delays, you've identified just one - the
> page timeout. By default this is just over 5 seconds, but it could be
> raised as high as 41 seconds.
>
> The page timeout, however, is applied only over the initial baseband
> connection. Before the connection complete event can be reported to the
> host, the LMP negotiation also has to take place. This can include
> authentication and pairing. In theory, the whole LMP negotiation should
> be bounded by a 30 second timeout, but, in practice I suspect it's better
> to err on the cautious side.
>
> Normally, this isn't a problem as you just wait for the connection
> complete event and it'll give a success or failure code. However, I
> understand that you want to detect non-responsive host controllers.

the kernel uses a connect timeout of 40 seconds. This was working fine
in the past.

> > your change is me too much at the moment. I simply changed the timeout
> > to 25000 for the hcitool cc command.
>
> If you want just a rough figure that'll probably work, I'd suggest
> assuming that the page timeout is about 10 seconds and allow the full
> 30 seconds LMP timeout. That'd give a 40 second timeout.
>
> If you wanted to be sure, then somwhere above 71 seconds is better, but
> to be really, really sure I suspect 2 minutes is better still.
>
> If this is too long, then I suggest a shorter timeout on the command
> status event. This event should always be reported promptly. You
> could get away with a one second timeout on that followed by a two
> minute timeout on the connection complete event.

I fully agree with you, but the "hcitool cc ..." is more for debugging
as for daily use. If people rely on it I can't help them, because in
general a ACL link should only be created by the kernel and not from
userspace. And this means the L2CAP layer would cause the Bluetooth core
to create the ACL link.

Regards

Marcel




-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
>From Windows to Linux, servers to mobile, InstallShield X is the
one installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2004-06-14 13:24:29

by Steven Singer

[permalink] [raw]
Subject: Re: [Bluez-devel] hci_create_connection assuming timeout too soon

Marcel Holtmann wrote:
>Andreas Gaufer wrote:
>> To catch a condition where the chip is stalled in some way i think the best
>> approach would be to time out on host side after the chips
>> page time out * 1,5 or so.

Even that might not be sufficient.

There are two potentially large delays, you've identified just one - the
page timeout. By default this is just over 5 seconds, but it could be
raised as high as 41 seconds.

The page timeout, however, is applied only over the initial baseband
connection. Before the connection complete event can be reported to the
host, the LMP negotiation also has to take place. This can include
authentication and pairing. In theory, the whole LMP negotiation should
be bounded by a 30 second timeout, but, in practice I suspect it's better
to err on the cautious side.

Normally, this isn't a problem as you just wait for the connection
complete event and it'll give a success or failure code. However, I
understand that you want to detect non-responsive host controllers.

> your change is me too much at the moment. I simply changed the timeout
> to 25000 for the hcitool cc command.

If you want just a rough figure that'll probably work, I'd suggest
assuming that the page timeout is about 10 seconds and allow the full
30 seconds LMP timeout. That'd give a 40 second timeout.

If you wanted to be sure, then somwhere above 71 seconds is better, but
to be really, really sure I suspect 2 minutes is better still.

If this is too long, then I suggest a shorter timeout on the command
status event. This event should always be reported promptly. You
could get away with a one second timeout on that followed by a two
minute timeout on the connection complete event.

- Steven
--




**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

http://www.mimesweeper.com
**********************************************************************

2004-06-12 09:45:16

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [Bluez-devel] hci_create_connection assuming timeout too soon

Hi Andreas,

> I noticed that many tools that use hci_create_connection use a hard coded
> timeout-value that varries between 1000 and 25000. 1000 is much to short for
> most mobile phones.
>
> This leads to error messages even if the chip didnt report a "connection
> complete" yet. Very often a conection complete with 00 is reported
> later but the tool did exit already.
>
> IMHO we could rely on the chips page timeout and wait for its "connection
> complete" event. This timeout can also be changed with hciconfig pageto
> by the user.
>
> To catch a condition where the chip is stalled in some way i think the best
> approach would be to time out on host side after the chips
> page time out * 1,5 or so.
>
> I changed hcitool to make it possible to specifiy the host side
> timeout via command line but i dont belive that this is a good aproach because
> it only fixes the symthoms not the root of the problem. Anyways I attach the
> patch against the latest CVS-HEAD to show what im talking about.
>
> In the moment my time is extremly short, i will try to bring up some code
> that realy helps here later. Since im not that familiar with C please let me
> know if somethings not right with my changes.

your change is me too much at the moment. I simply changed the timeout
to 25000 for the hcitool cc command.

Regards

Marcel




-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
>From Windows to Linux, servers to mobile, InstallShield X is the
one installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel