Bug 1278

Summary: Ipv4ClickRouting::HandleScheduleFromClick should stay integer for delay calculation to be accurate
Product: ns-3 Reporter: lichtblau <lichtbla>
Component: clickAssignee: Lalith Suresh <suresh.lalith>
Status: RESOLVED FIXED    
Severity: normal CC: ns-bugs
Priority: P5    
Version: pre-release   
Hardware: All   
OS: All   
Attachments: patch
example script
example click script

Description lichtblau 2011-10-12 18:48:16 UTC
Created attachment 1253 [details]
patch

attached patch fixes the problem, adds a debug message in RunClickEvent and corrects a debug message in simclick_click_command.
Comment 1 lichtblau 2011-10-12 18:49:36 UTC
Created attachment 1254 [details]
example script
Comment 2 lichtblau 2011-10-12 18:50:27 UTC
Created attachment 1255 [details]
example click script
Comment 3 Lalith Suresh 2011-10-13 09:51:08 UTC
Thanks.

Just to confirm, the test case doesn't offer any difference in the simulation runs, right?
Comment 4 lichtblau 2011-10-13 10:06:51 UTC
It does if you also add the additional debug message in RunClickEvent, but i refrained from posting a log here because my click output is currently cluttered with messages (and you may not be able see it because of the click scheduling problems i just posted to the click mailing list, easiest workaround without touching click is to call simclick_click_run twice in RunClickEvent).

On my system without the patch you can see how ns3 calls click too early due to rounding errors, click calls for getting scheduled at 1 sec 1000 usecs but ns3 already runs it at 1 sec 999 usecs (and you can see how click handles it, as the timer does not fire there it just reschedules):

0s Ipv4ClickRouting:DoStart(): Node0 has initialised a Click Router
txing :  113 | 00000c00 04040300 0000000c 08000000 ffffffff ffff0000 00000000 00000000 00000000 aaaa0300 0000bbbb 52616e64 6f6d
0s Ipv4ClickRouting:HandleScheduleFromClick(): HandleScheduleFromClick at 0 501000 +0.0ns
0s Ipv4ClickRouting:simclick_sim_command(): Node0 SIMCLICK_SCHEDULE at 0s and 501000usecs.
0.501s Ipv4ClickRouting:RunClickEvent(): RunClickEvent at 0 501000 +501000000.0ns
txing :  113 | 00000c00 04040300 0000000c 08000000 ffffffff ffff0000 00000000 00000000 00000000 aaaa0300 0000bbbb 52616e64 6f6d
0.501s Ipv4ClickRouting:HandleScheduleFromClick(): HandleScheduleFromClick at 1 1000 +501000000.0ns
0.501s Ipv4ClickRouting:simclick_sim_command(): Node0 SIMCLICK_SCHEDULE at 1s and 1000usecs.
1.001s Ipv4ClickRouting:RunClickEvent(): RunClickEvent at 1 999 +1000999999.0ns
1.001s Ipv4ClickRouting:HandleScheduleFromClick(): HandleScheduleFromClick at 1 1000 +1000999999.0ns
1.001s Ipv4ClickRouting:simclick_sim_command(): Node0 SIMCLICK_SCHEDULE at 1s and 1000usecs.
1.001s Ipv4ClickRouting:RunClickEvent(): RunClickEvent at 1 1000 +1001000998.0ns
txing :  113 | 00000c00 04040300 0000000c 08000000 ffffffff ffff0000 00000000 00000000 00000000 aaaa0300 0000bbbb 52616e64 6f6d
....

With the patch this does not happen, sorry for not pointing this out yesterday, too late ;)
Comment 5 Lalith Suresh 2011-10-13 16:03:15 UTC
(In reply to comment #4)
> It does if you also add the additional debug message in RunClickEvent, but i
> refrained from posting a log here because my click output is currently
> cluttered with messages (and you may not be able see it because of the click
> scheduling problems i just posted to the click mailing list, easiest workaround
> without touching click is to call simclick_click_run twice in RunClickEvent).
> 
> On my system without the patch you can see how ns3 calls click too early due to
> rounding errors, click calls for getting scheduled at 1 sec 1000 usecs but ns3
> already runs it at 1 sec 999 usecs (and you can see how click handles it, as
> the timer does not fire there it just reschedules):
> 
> 0s Ipv4ClickRouting:DoStart(): Node0 has initialised a Click Router
> txing :  113 | 00000c00 04040300 0000000c 08000000 ffffffff ffff0000 00000000
> 00000000 00000000 aaaa0300 0000bbbb 52616e64 6f6d
> 0s Ipv4ClickRouting:HandleScheduleFromClick(): HandleScheduleFromClick at 0
> 501000 +0.0ns
> 0s Ipv4ClickRouting:simclick_sim_command(): Node0 SIMCLICK_SCHEDULE at 0s and
> 501000usecs.
> 0.501s Ipv4ClickRouting:RunClickEvent(): RunClickEvent at 0 501000
> +501000000.0ns
> txing :  113 | 00000c00 04040300 0000000c 08000000 ffffffff ffff0000 00000000
> 00000000 00000000 aaaa0300 0000bbbb 52616e64 6f6d
> 0.501s Ipv4ClickRouting:HandleScheduleFromClick(): HandleScheduleFromClick at 1
> 1000 +501000000.0ns
> 0.501s Ipv4ClickRouting:simclick_sim_command(): Node0 SIMCLICK_SCHEDULE at 1s
> and 1000usecs.
> 1.001s Ipv4ClickRouting:RunClickEvent(): RunClickEvent at 1 999 +1000999999.0ns
> 1.001s Ipv4ClickRouting:HandleScheduleFromClick(): HandleScheduleFromClick at 1
> 1000 +1000999999.0ns
> 1.001s Ipv4ClickRouting:simclick_sim_command(): Node0 SIMCLICK_SCHEDULE at 1s
> and 1000usecs.
> 1.001s Ipv4ClickRouting:RunClickEvent(): RunClickEvent at 1 1000
> +1001000998.0ns
> txing :  113 | 00000c00 04040300 0000000c 08000000 ffffffff ffff0000 00000000
> 00000000 00000000 aaaa0300 0000bbbb 52616e64 6f6d
> ....
> 
> With the patch this does not happen, sorry for not pointing this out yesterday,
> too late ;)

Thanks for clarifying!

Pushed to ns-3-dev.

changeset:   7558:0d04b625ea54
tag:         tip
user:        Björn Lichtblau
date:        Thu Oct 13 21:55:21 2011 +0200
summary:     Bug 1278: Ipv4ClickRouting::HandleScheduleFromClick should stay integer for delay calculation to be accurate