Friday, October 23, 2015

An Introduction to Port Mirroring in Broadcom Switches

Port Mirroring:
                Port mirroring is a way to redirect a copy of packets coming to (ingress) or going out (egress) of a port to another port. It will be helpful to analyze the correctness/content of a packet and it can be used as a best debugging method.

Example:
Consider the below scenario.




        In the above topology, two networks are connected via a router. Now, if we want to capture the traffic that flows between these two networks without disturbing the connections, then port mirroring will be helpful. Here we can mirror the traffic of either Port 1 or Port 3 to Port2. So we can analyze the traffic content without disturbing the topology.

Port Mirroring commands in BCM:

                The below commands are used to enable the port mirroring functionality in Broadcom switches.


S.No Command Purpose
1 mirror mode=l2 port=x This command will do mirroring of all traffic from all ports to port "x". The mode can accept the value of l2 or l3.
2 mirror mode=l2 port=x IngressBitMap=y All the incoming packets to port “y” will be mirrored to port “x”. It is not necessary that both port “x” & “y” to be in the same VLAN.
3 mirror mode=l2 port=x EgressBitMap=y All packets going out of port “y” will be mirrored to port “x”.
4 mir It will display the current port mirror settings.
5 help mirror It will display the help on the port mirroring commands

Wednesday, October 21, 2015

Basic Broadcom Switch commands to verify the details of the hardware table


The below commands are very useful to debug the broadcom switches.


S.No Purpose Command
1 To verify the mac address table l2 show
2 To verify the ingress vlan translation table vlan translate show
3 To verify the egress vlan translation table vlan translate egress show
4 To verify the MSTP instances stg show
5 To verify the port status ps
6 To verify the vlan entires in hardware vlan show
7 To verify the trunk port configuration trunk show
8 To enable bcm debug messages dbm bcm +api
9 To disable bcm debug messages dbm bcm -api
10 To get the number of entries in the hardware L2 Table (Mac Address Table) get SYS_MAC_COUNT
11 To clear the L2Table entries in hardware clear L2_ENTRY

Sunday, October 11, 2015

Removing special/unwanted characters from linux "script" command output file

What is "script":
        Linux is having an utility to log the output displayed on the screen console. This utility is invoked using the "script" command.

How to invoke script:
       script <file-name>
       The above command will create a text file in the "file-name" and then will start to log all the outputs displayed on the screen into this file.

        Note: If  the file with name "file-name" already present, then it will be overwritten.

Formatting the "script" output file:
        The output file generated using the script command, will have some special/unwanted characters. These can be cleaned up using the "vim" editor's regular expression matching.
        In most cases, you will find the special characters like ^M, ^H, etc. in the output of script command. This can be cleaned up using the below "vim" commands.

StepCommand
Open the file using vim editorvim "file-name"
Go to the command modePress ESC key
Give the command.
This command will remove all the occurrences of the character "^M". The "&lt;ctrl-v><ctrl-m>" combination will be encoded to "^M"
:%s/<ctrl-v><ctrl-m>//g 
  •   Note: Similarly we can give remove any special characters using the combination of "<ctrl-v><ctrl-X>", where X = H,G, or any special character present in the file.
  •  If the character "^M" present at the end of the line, then use the command "":%s/<ctrl-v><ctrl-m>\n/\r/g" to replace it with the line break.