5353import org .pcap4j .packet .namednumber .IpVersion ;
5454import org .pcap4j .util .ByteArrays ;
5555import org .pcap4j .util .MacAddress ;
56+ import org .slf4j .Logger ;
57+ import org .slf4j .LoggerFactory ;
5658
5759public class IPv6NeighborDiscoveryService {
5860
5961 private static final EtherType QInQ =
6062 new EtherType ((short ) 0x88a8 , "802.1Q Provider Bridge (Q-in-Q)" );
61- private static final int L3LENGTH = 40 ;
62- private static final int L2LENGTH = 14 ;
63+ private static final Logger LOGGER = LoggerFactory .getLogger (IPv6NeighborDiscoveryService .class );
6364 private TRexClient tRexClient ;
6465
6566 public IPv6NeighborDiscoveryService (TRexClient tRexClient ) {
@@ -212,11 +213,10 @@ public EthernetPacket sendNeighborSolicitation(
212213 String dstIp ) {
213214 long endTs = System .currentTimeMillis () + timeout * 1000 ;
214215
215- if (dstMac == null ) {
216- dstMac = multicastMacFromIPv6 (dstIp ).toString ();
217- }
216+ final String multicastMac = dstMac != null ? dstMac : multicastMacFromIPv6 (dstIp ).toString ();
218217
219- Packet icmpv6NSPkt = buildICMPV6NSPkt (vlan , srcMac , dstMac , dstIp , srcIp );
218+ Packet icmpv6NSPkt = buildICMPV6NSPkt (vlan , srcMac , multicastMac , dstIp , srcIp );
219+ LOGGER .trace ("Sending IPv6 Neighbor Solicitation packet:\n {}" , icmpv6NSPkt );
220220 tRexClient .startStreamsIntermediate (portIdx , Arrays .asList (buildStream (icmpv6NSPkt )));
221221
222222 Predicate <EthernetPacket > ipV6NAPktFilter =
@@ -360,8 +360,8 @@ private static com.cisco.trex.stateless.model.Stream buildStream(
360360 0 ,
361361 0.0 ,
362362 new StreamMode (
363- 2 ,
364- 2 ,
363+ 10 ,
364+ 10 ,
365365 5 ,
366366 1.0 ,
367367 new StreamModeRate (StreamModeRate .Type .percentage , 100.0 ),
@@ -375,7 +375,7 @@ private static com.cisco.trex.stateless.model.Stream buildStream(
375375 null );
376376 }
377377
378- private static Packet buildICMPV6NSPkt (
378+ static Packet buildICMPV6NSPkt (
379379 PortVlan vlan , String srcMac , String dstMac , String dstIp , String srcIp ) {
380380 EthernetPacket .Builder ethBuilder = new EthernetPacket .Builder ();
381381 try {
0 commit comments