Bug 69

Summary: Source IP address is not set correctly
Product: ns-3 Reporter: Craig Dowell <craigdo>
Component: internetAssignee: ns-bugs <ns-bugs>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P1    
Version: pre-release   
Hardware: All   
OS: All   
Bug Depends on: 65    
Bug Blocks:    
Attachments: patch extracted from craigdo/ns-3-mc
Additional patch for Source IP 0.0.0.0
this patch supersedes previous 2, and depends on bug65.patch
UDP broadcast; builds on previous patch
fix for Mathieu's comment

Description Craig Dowell 2007-08-14 15:04:11 UTC
Packets sent (at least via sockets) have a source IP address of 0.0.0.0
Comment 1 Tom Henderson 2007-08-23 02:26:43 UTC
Created attachment 46 [details]
patch extracted from craigdo/ns-3-mc
Comment 2 Joe Kopena 2007-08-24 15:24:44 UTC
Created attachment 47 [details]
Additional patch for Source IP 0.0.0.0

Minor changes to UDPSocket to fix SendTo()/Connect() and 0 Source IP problems.  **Note that this requires Tom's patch for this be applied first.**

Changes include:

- Making source IP addresses be reoprted correctly when using SendTo()
- Enable using Connect() to provide optional defaults for Send(), overridden by using SendTo()
Comment 3 Tom Henderson 2007-09-04 02:38:10 UTC
Created attachment 49 [details]
this patch supersedes previous 2, and depends on bug65.patch
Comment 4 Tom Henderson 2007-09-05 02:28:47 UTC
Created attachment 50 [details]
UDP broadcast; builds on previous patch

This supports UDP broadcast to 255.255.255.255; each such packet is converted to a subnet-directed broadcast and sent out on each Ipv4 interface.  

I provided an example program (csma-broadcast.cc) that tests this behavior; however, I had to slightly hack OnOffApplication because it uses UDP connect(), which is incompatible with broadcast.

So, we either need to clean up OnOffApplication to use SendTo(), or find a new sample application (UDP ping?) for csma-broadcast.cc.
Comment 5 Mathieu Lacage 2007-09-05 02:34:19 UTC
Why is it impossible to use 255....255 as an argument to Connect ? I know that it will not work for tcp sockets, but we just need to define what happens with udp sockets and document it somewhere, in udp-socket.h for example (in a similar way to the packet-socket.h header).
Comment 6 Tom Henderson 2007-09-05 02:46:53 UTC
I thought it was illegal, but just checked and discovered that it is legal but such a connected socket is limited to exchanging datagrams with only one peer.

So I think it is probably best to just fix it so that connect can work (I had put the restriction into udp-socket and can revert that).
Comment 7 Tom Henderson 2007-09-05 03:02:04 UTC
Created attachment 51 [details]
fix for Mathieu's comment

This fixes two things:
- allows connect() to broadcast address (and reverts the hack on OnOffApplication)
- fixes semantics of SendTo() for connected socket-- sendto cannot overwrite the default addr/port of a connected socket
Comment 8 Tom Henderson 2007-09-08 18:18:00 UTC
fixed by ns-3-dev changesets 1317 and 1318
Comment 9 Gustavo J. A. M. Carneiro 2007-09-21 09:44:55 UTC
Oops, sorry, didn't mean to reopen this bug... bad bugzilla interface! :P