Doubt in simulation and pcap generated

68 views
Skip to first unread message

Anuja Tayal

unread,
Nov 24, 2017, 10:54:33 AM11/24/17
to ns-3-users
Hi

I wrote a small program (matrix.cc) where three random nodes send udp packets to 3 other random nodes in a 10-node topology. By generating the pcap file, I am trying to calculate number of packets from each node.

I have following doubts:
1) In following piece of code

Ptr<Node> n = nodes.Get (rn1);

Ptr<Ipv4> ipv4 = n->GetObject<Ipv4> ();

Ipv4InterfaceAddress ipv4_int_addr =ipv4->GetAddress (1, 0);

                   

Every time, the interface address to rn1 will be same, but I want to transfer packet through the interface of the node I am sending the packet. How to get that interface ip address?


2) I have a problem understanding how pcap files generated in ns3 are named and the content.(attached sample screenshot) 
3) After running the code, in the pcap ICMP Destination unreachable packets are also there. I don't understand the reason for the same.

Please help me. Its urgent. And I am hopeless.
Thanks and Regards
Anuja Tayal
adjacency_matrix.txt
node_coordinates.txt
matrix.cc
matrix-main 1-3 pcap screenshot.png

Tommaso Pecorella

unread,
Nov 25, 2017, 8:11:37 AM11/25/17
to ns-3-users
Hi,

1: the output interface is chosen by routing. You can forcefully use one, but it's not a good idea.
2: PCAPs are named <prefix>_<node number>_<interface number>.pcap
3: you set the sink on port 8080 and sender is sending to port 9.

T.

Anuja Tayal

unread,
Nov 29, 2017, 3:25:57 AM11/29/17
to ns-3-users
Hi

Thanks a lot for solving my doubts.
1. But while sending packets, we need to specify the interface (1,0), in this case, we want to receive the packets.
    Ptr<Node> n = nodes.Get (rn1);

  Ptr<Ipv4> ipv4 = n->GetObject<Ipv4> ();
  Ipv4InterfaceAddress ipv4_int_addr = ipv4->GetAddress (1,0);
  Ipv4Address ip_addr = ipv4_int_addr.GetLocal ();
  OnOffHelper onoff ("ns3::UdpSocketFactory", InetSocketAddress (ip_addr, port));

       
Can you suggest an alternative way.
         
Thanks
Anuja

Tommaso Pecorella

unread,
Nov 30, 2017, 6:15:55 PM11/30/17
to ns-3-users
That's the IP number you want to send the data TO, not FROM.

Please describe better your issue, I honestly can't understand it. 

T.
Reply all
Reply to author
Forward
0 new messages