Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#147 TCP: Source address is from routing table not from -i flag

v3.3
open
nobody
None
2
2015-02-16
2014-06-16
aikchar
No

Short Description

When using "-t tn" and "-i myip" the IP used to send messages is not myip but the IP from the OS (Linux) routing table.

Steps to Reproduce

  • On the "server" side start netcat

    nc -v -l 10.10.0.55 5060
    
  • On the "client" side run built-in UAC scenario using -t tn and -i myip

    sipp -sn uac -i 10.10.0.5 -t tn -p 5060 -m 1 -r 1 -trace_msg -message_file run.msg -trace_stat -stf run.stat -trace_err -trace_screen -error_file run.err -send_timeout 5000 -recv_timeout 5000 10.10.0.55
    
  • On the "server" side you'll see something like this on the output on netcat

    Connection from 10.10.0.4 port 5060 [tcp/*] accepted
    INVITE sip:service@10.10.0.55:5060 SIP/2.0
    Via: SIP/2.0/TCP 10.10.0.5:5060;branch=z9hG4bK-2202-1-0
    From: sipp <sip:sipp@10.10.0.5:5060>;tag=2202SIPpTag001
    To: service <sip:service@10.10.0.55:5060>
    Call-ID: 1-2202@10.10.0.5
    CSeq: 1 INVITE
    Contact: sip:sipp@10.10.0.5:5060
    Max-Forwards: 70
    Subject: Performance Test
    Content-Type: application/sdp
    Content-Length:   129
    
    v=0
    o=user1 53655765 2353687637 IN IP4 10.10.0.5
    s=-
    c=IN IP4 10.10.0.5
    t=0 0
    m=audio 6000 RTP/AVP 0
    a=rtpmap:0 PCMU/8000
    

Observed Result

If you look at the first line of the nc output it says the connection is from 10.10.0.4 instead of 10.10.0.5 (the IP we provided with the -i flag).

I have also tried -ci flag with the same result.

If I use -t un flag then the first line of output of nc is "Connection from 10.10.0.5 port 5060 [udp/*] accepted".

Expected Result

The IP 10.10.0.5 should be used whether -t is tn or un when making connections.

Client Environment

aikchar@opensuse:~/sipp/run> ip a s
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 brd 127.255.255.255 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:50:56:01:c5:95 brd ff:ff:ff:ff:ff:ff
    inet 10.145.194.238/18 brd 10.145.255.255 scope global ens32
       valid_lft forever preferred_lft forever
    inet6 fe80::250:56ff:fe01:c595/64 scope link 
       valid_lft forever preferred_lft forever
3: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:50:56:01:c5:96 brd ff:ff:ff:ff:ff:ff
    inet 10.10.0.4/22 brd 10.10.3.255 scope global ens33
       valid_lft forever preferred_lft forever
    inet 10.10.0.5/22 brd 10.10.3.255 scope global secondary ens33:add1
       valid_lft forever preferred_lft forever
    inet6 fe80::250:56ff:fe01:c596/64 scope link 
       valid_lft forever preferred_lft forever
4: ens34: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:50:56:01:c5:97 brd ff:ff:ff:ff:ff:ff
    inet 10.20.0.4/22 brd 10.20.3.255 scope global ens34
       valid_lft forever preferred_lft forever
    inet6 fe80::250:56ff:fe01:c597/64 scope link 
       valid_lft forever preferred_lft forever

aikchar@opensuse:~/sipp/run> ip r s
default via 10.145.255.254 dev ens32 
10.10.0.0/22 dev ens33  proto kernel  scope link  src 10.10.0.4 
10.20.0.0/22 dev ens34  proto kernel  scope link  src 10.20.0.4 
10.145.192.0/18 dev ens32  proto kernel  scope link  src 10.145.194.238 
127.0.0.0/8 dev lo  scope link

Server Environment

[aikchar@centos ~]$ ip a s
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:50:56:01:c3:96 brd ff:ff:ff:ff:ff:ff
    inet 10.145.194.226/18 brd 10.145.255.255 scope global eth0
    inet6 fe80::250:56ff:fe01:c396/64 scope link 
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:50:56:01:c3:97 brd ff:ff:ff:ff:ff:ff
    inet 10.10.0.2/22 brd 10.10.3.255 scope global eth1
    inet 10.10.0.51/22 scope global secondary eth1:1
    inet 10.10.0.52/22 scope global secondary eth1:2
    inet 10.10.0.53/22 scope global secondary eth1:3
    inet 10.10.0.54/22 scope global secondary eth1:4
    inet 10.10.0.55/22 scope global secondary eth1:5
    inet 10.10.0.56/22 scope global secondary eth1:6
    inet 10.10.0.57/22 scope global secondary eth1:7
    inet 10.10.0.58/22 scope global secondary eth1:8
    inet 10.10.0.59/22 scope global secondary eth1:9
    inet 10.10.0.60/22 scope global secondary eth1:10
    inet 10.10.0.61/22 scope global secondary eth1:11
    inet 10.10.0.62/22 scope global secondary eth1:12
    inet 10.10.0.63/22 scope global secondary eth1:13
    inet 10.10.0.64/22 scope global secondary eth1:14
    inet 10.10.0.65/22 scope global secondary eth1:15
    inet 10.10.0.66/22 scope global secondary eth1:16
    inet 10.10.0.67/22 scope global secondary eth1:17
    inet 10.10.0.68/22 scope global secondary eth1:18
    inet 10.10.0.69/22 scope global secondary eth1:19
    inet 10.10.0.70/22 scope global secondary eth1:20
    inet6 2002::10:10:0:64/96 scope global 
       valid_lft forever preferred_lft forever
    inet6 2002::10:10:0:63/96 scope global 
       valid_lft forever preferred_lft forever
    inet6 2002::10:10:0:62/96 scope global 
       valid_lft forever preferred_lft forever
    inet6 2002::10:10:0:61/96 scope global 
       valid_lft forever preferred_lft forever
    inet6 2002::10:10:0:60/96 scope global 
       valid_lft forever preferred_lft forever
    inet6 2002::10:10:0:5f/96 scope global 
       valid_lft forever preferred_lft forever
    inet6 2002::10:10:0:5e/96 scope global 
       valid_lft forever preferred_lft forever
    inet6 2002::10:10:0:5d/96 scope global 
       valid_lft forever preferred_lft forever
    inet6 2002::10:10:0:5c/96 scope global 
       valid_lft forever preferred_lft forever
    inet6 2002::10:10:0:5b/96 scope global 
       valid_lft forever preferred_lft forever
    inet6 2002::10:10:0:5a/96 scope global 
       valid_lft forever preferred_lft forever
    inet6 2002::10:10:0:59/96 scope global 
       valid_lft forever preferred_lft forever
    inet6 2002::10:10:0:58/96 scope global 
       valid_lft forever preferred_lft forever
    inet6 2002::10:10:0:57/96 scope global 
       valid_lft forever preferred_lft forever
    inet6 2002::10:10:0:56/96 scope global 
       valid_lft forever preferred_lft forever
    inet6 2002::10:10:0:55/96 scope global 
       valid_lft forever preferred_lft forever
    inet6 2002::10:10:0:54/96 scope global 
       valid_lft forever preferred_lft forever
    inet6 2002::10:10:0:53/96 scope global 
       valid_lft forever preferred_lft forever
    inet6 2002::10:10:0:52/96 scope global 
       valid_lft forever preferred_lft forever
    inet6 2002::10:10:0:51/96 scope global 
       valid_lft forever preferred_lft forever
    inet6 fe80::250:56ff:fe01:c397/64 scope link 
       valid_lft forever preferred_lft forever
4: eth2: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:50:56:01:c3:98 brd ff:ff:ff:ff:ff:ff
5: ip6tnl0: <NOARP> mtu 1460 qdisc noop 
    link/tunnel6 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 brd 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00

[aikchar@centos ~]$ ip r s
10.10.0.0/22 dev eth1  proto kernel  scope link  src 10.10.0.2 
10.20.0.0/22 via 10.10.0.1 dev eth1 
10.145.192.0/18 dev eth0  proto kernel  scope link  src 10.145.194.226 
169.254.0.0/16 dev eth0  scope link  metric 1002 
169.254.0.0/16 dev eth1  scope link  metric 1003 
169.254.0.0/16 dev eth2  scope link  metric 1004 
default via 10.145.255.254 dev eth0
1 Attachments

Discussion

  • aikchar
    aikchar
    2014-06-16

    The version of SIPp tried:

    aikchar@opensuse:~/sipp/run> sipp -v
    SIPp v3.3-TLS-SCTP-PCAP, built Jun 23 2013, 00:25:41.
    ...
    
     
  • aikchar
    aikchar
    2014-07-03

    A workaround I found was to add a SNAT rule to iptables to re-write the IP address. You may need to change the values according to your environment.

    iptables -t nat -A POSTROUTING -o eth0 -p tcp ! --sport 5060 -d 192.168.1.21 --dport 5060 -j SNAT --to-source 192.168.1.15

    You can delete this rule when not needed.

    iptables -t nat -D POSTROUTING -o eth0 -p tcp ! --sport 5060 -d 192.168.1.21 --dport 5060 -j SNAT --to-source 192.168.1.15