OpenIxia / IxNetwork

A central location for IxNetwork sample scripts and utilities. Please also visit http://openixia.com
MIT License
50 stars 59 forks source link

Using a list for Mac addresses instead of increment #60

Closed imehrdad2012 closed 5 years ago

imehrdad2012 commented 5 years ago

Hello,

In my IXIA application, I create a raw traffic item where I need to pass a list of mac addresses rather than doing auto increment (like the following). How can I achieve this in RestPy? ( I know how to do this in IxNetwork but could not see any example in this repo.) Thanks!

ixNetwork.info('Configuring Ethernet packet header')
ethernetDstField = ethernetStackObj.Field.find(DisplayName='Destination MAC Address')
ethernetDstField.ValueType = 'increment'
ethernetDstField.StartValue = "00:00:00:40:08:02"
ethernetDstField.StepValue = "00:00:00:00:00:00"
ethernetDstField.CountValue = 1
therkong commented 5 years ago

Hi Mehrdad,

you can set the ValueType = 'valueList'. See example:

ixNetwork.info('Configuring Ethernet packet header')

ethernetDstField = ethernetStackObj.Field.find(DisplayName='Destination MAC Address')

ethernetDstField.ValueType = 'valueList'

ethernetDstField.ValueList = ["00:00:00:40:08:02", "00:00:00:40:08:03", "00:00:00:40:08:05"]

Give it a try.

Regards,

Theresa Kong Senior Tech Support Engineer Keysight Technologies

From: Mehrdad Moradi notifications@github.com Sent: Wednesday, May 8, 2019 4:50 PM To: OpenIxia/IxNetwork IxNetwork@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [OpenIxia/IxNetwork] Using a list for Mac addresses instead of increment (#60)

[EXTERNAL]

Hello,

In my IXIA application, I create a raw traffic item where I need to pass a list of mac addresses rather than doing auto increment (like the following). How can I achieve this in RestPy? ( I know how to do this in IxNetwork but could not see any example in this repo.) Thanks!

ixNetwork.info('Configuring Ethernet packet header')

ethernetDstField = ethernetStackObj.Field.find(DisplayName='Destination MAC Address')

ethernetDstField.ValueType = 'increment'

ethernetDstField.StartValue = "00:00:00:40:08:02"

ethernetDstField.StepValue = "00:00:00:00:00:00"

ethernetDstField.CountValue = 1

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FOpenIxia%2FIxNetwork%2Fissues%2F60&data=02%7C01%7C%7C1b531b6221d74986398608d6d40ff377%7C63545f2732324d74a44dcdd457063402%7C1%7C0%7C636929562312875866&sdata=0gA4YA7wmgO4VNPGuG%2FLUf7dvJ6dSKAfmTzCnmlgkTw%3D&reserved=0, or mute the threadhttps://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAIRRUUJ3KASP5CMZZNGEANLPUNRMJANCNFSM4HLWBRAQ&data=02%7C01%7C%7C1b531b6221d74986398608d6d40ff377%7C63545f2732324d74a44dcdd457063402%7C1%7C0%7C636929562312875866&sdata=8viaZA1T8azWLJ7xz9nj3FT9QgH%2FjC2SYZYAduSddVU%3D&reserved=0.

memoradi commented 5 years ago

Thanks, Theresa. It worked!

After defining the list of mac addresses, I would like to turn on the full-mesh communication. Can you please provide any pointer on how I should do that?

BTW, any documentation for RestPy is highly appreciated.

therkong commented 5 years ago

RestPy doc can be found where you installed the ixnetwork_restpy package. If you installed it using pip install. It gets installed on /Lib/site-packages. The doc is in /Lib/site-packages/ixnetork_restpy/docs dir. Open the index.html under the doc dir

Which field do you want to do “full-mesh”? You’re referring to traffic, correct? Are you doing Layer 2 or Layer 3 traffic?

Regards,

Theresa Kong Senior Tech Support Engineer Keysight Technologies

From: memoradi notifications@github.com Sent: Thursday, May 9, 2019 11:10 AM To: OpenIxia/IxNetwork IxNetwork@noreply.github.com Cc: Theresa Kong theresa.kong@keysight.com; Assign assign@noreply.github.com Subject: Re: [OpenIxia/IxNetwork] Using a list for Mac addresses instead of increment (#60)

[EXTERNAL]

Thanks, Theresa. It worked!

After defining the list of mac addresses, I would like to turn on the full-mesh communication. Can you please provide any pointer on how I should do that?

BTW, any documentation for RestPy is highly appreciated.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHubhttps://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FOpenIxia%2FIxNetwork%2Fissues%2F60%23issuecomment-491008718&data=02%7C01%7C%7Cd70ad66602cf444e33a908d6d4a99210%7C63545f2732324d74a44dcdd457063402%7C1%7C0%7C636930222098819683&sdata=tboTGhuc2VsMoAY49vGirQNLZGdakMGXE%2FGNIcLpJiU%3D&reserved=0, or mute the threadhttps://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAIRRUUMV3FMAC7F36SHYJR3PURSH7ANCNFSM4HLWBRAQ&data=02%7C01%7C%7Cd70ad66602cf444e33a908d6d4a99210%7C63545f2732324d74a44dcdd457063402%7C1%7C0%7C636930222098819683&sdata=afaTpWbp6MjHHeZWXw1VhtDBUIx9UeETuUSeIKO6xEk%3D&reserved=0.

memoradi commented 5 years ago

Thanks for the pointer on the documentation.

I am creating VLAN-tagged IPV4 traffic in my test. In my configuration, the src/dest IPs and src/dst mac addresses are stored in a list, e.g.,

Source IP = [A,B,C] Dest IP = [C,D,E] Src Mac = [X Y Z] dst Mac = [W M N]

I'd like to send packets [A,C, X, W], [B, D, Y, M], and [C,E,Z,N]. I know how to this in IxNetwork (using one-to-one, full-mesh,.. options). Q1: can you please point me on how to enable this in IXIA RestPy? Q2: For debugging purposes, Is there any way to store packets (e.g., in JSON format) using the IXIA RestPy API? I would like to get something similar to IxExplorer's packet view option.

hubertgee commented 5 years ago

Also, for convenience, the doc is in our openixia website: https://www.openixia.com/userGuides/restPyDoc

Regards, Hubert Gee

From: memoradi notifications@github.com Sent: Thursday, May 9, 2019 12:38 PM To: OpenIxia/IxNetwork IxNetwork@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: Re: [OpenIxia/IxNetwork] Using a list for Mac addresses instead of increment (#60)

[EXTERNAL]

Thanks for the pointer on the documentation.

I am creating VLAN-tagged IPV4 traffic in my test. In my configuration, the src/dest IPs and src/dst mac addresses are stored in a list, e.g.,

Source IP = [A,B,C] Dest IP = [C,D,E] Src Mac = [X Y Z] dst Mac = [W M N]

I'd like to send packets [A,C, X, W], [B, D, Y, M], and [C,E,Z,N]. I know how to this in IxNetwork (using one-to-one, full-mesh,.. options). Q1: can you please point me on how to enable this in IXIA RestPy? Q2: For debugging purposes, Is there any way to store packets (e.g., in JSON format) using the IXIA RestPy API? I would like to get something similar to IxExplorer's packet view option.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FOpenIxia%2FIxNetwork%2Fissues%2F60%23issuecomment-491037806&data=02%7C01%7C%7C1cbd6d469579421052a008d6d4b5dd1f%7C63545f2732324d74a44dcdd457063402%7C1%7C0%7C636930274909813009&sdata=mPE%2F3DU2dLIV9odG9p9yt8GpiHtcuyeEhDXrJ%2BlQpT4%3D&reserved=0, or mute the threadhttps://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAINVQX5EJK3UOCALVLNDKH3PUR4R7ANCNFSM4HLWBRAQ&data=02%7C01%7C%7C1cbd6d469579421052a008d6d4b5dd1f%7C63545f2732324d74a44dcdd457063402%7C1%7C0%7C636930274909823005&sdata=OyyzWbH0meH6XZjVEK9gvfHlmkZ3U7qhHtrvR4eLt74%3D&reserved=0.

therkong commented 5 years ago

Are you creating traffic item with endpointSet or raw traffic? Both examples are in createTrafficItemAddPacketHeader.py

endpointSet: def createTrafficItem(**kwargs)

raw: def createPacketHeader(trafficItemObj, packetHeaderToAdd=None, appendToStack=None)

If you’re creating traffic item with endpoinetSet, then you need to create Ethernet Stack and IP stack under topology/deviceGroup with the valueList that you desire. If you’re creating raw traffic item, then when you append ethernet src/dest mac stack in the traffic item, you need to set ValueType to ‘valueList’ and set the ValueList. Do the same for src/dest IP stack.

Regarding your Q2, I need to check. I will get back to you on this.

Regards,

Theresa Kong Senior Tech Support Engineer Keysight Technologies

From: memoradi notifications@github.com Sent: Thursday, May 9, 2019 12:38 PM To: OpenIxia/IxNetwork IxNetwork@noreply.github.com Cc: Theresa Kong theresa.kong@keysight.com; Assign assign@noreply.github.com Subject: Re: [OpenIxia/IxNetwork] Using a list for Mac addresses instead of increment (#60)

[EXTERNAL]

Thanks for the pointer on the documentation.

I am creating VLAN-tagged IPV4 traffic in my test. In my configuration, the src/dest IPs and src/dst mac addresses are stored in a list, e.g.,

Source IP = [A,B,C] Dest IP = [C,D,E] Src Mac = [X Y Z] dst Mac = [W M N]

I'd like to send packets [A,C, X, W], [B, D, Y, M], and [C,E,Z,N]. I know how to this in IxNetwork (using one-to-one, full-mesh,.. options). Q1: can you please point me on how to enable this in IXIA RestPy? Q2: For debugging purposes, Is there any way to store packets (e.g., in JSON format) using the IXIA RestPy API? I would like to get something similar to IxExplorer's packet view option.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHubhttps://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FOpenIxia%2FIxNetwork%2Fissues%2F60%23issuecomment-491037806&data=02%7C01%7C%7C11a8c2e85b634c88e86608d6d4b5dcf2%7C63545f2732324d74a44dcdd457063402%7C1%7C0%7C636930274888399233&sdata=H3xbzCs6IsKNyTWv3oJx8CrOuIFDglLAd%2B2NmjXHby4%3D&reserved=0, or mute the threadhttps://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAIRRUUPWBN7GWWMFPNOVGD3PUR4R7ANCNFSM4HLWBRAQ&data=02%7C01%7C%7C11a8c2e85b634c88e86608d6d4b5dcf2%7C63545f2732324d74a44dcdd457063402%7C1%7C0%7C636930274888399233&sdata=cWSLQjmEZeq7ZeEMS7bPwzelWUI3NiCJGpsENbY6wvE%3D&reserved=0.

therkong commented 5 years ago

Regarding Q2- you can export the traffic item to json file, then download the file to your script machine: ixnetwork.ResourceManager.ExportConfigFile(['/traffic/trafficItem[1]/descendant-or-self::*'], False, 'json', Files('ti1.json')) local_filename = sessions.DownloadFile('ti1.json', 'ti1_local.json')

You can view ti1_local.json file. The format will NOT be the same as Packet View in IxExplorer GUI. However, it will contain every field and it's settings. Please give it a try. If you have any issues, you can open a support ticket by sending email to support.ix@keysight.com. I can help you in more detail.

memoradi commented 5 years ago

Thanks, @therkong, and @hubertgee. I will create a ticket as I got more questions.

memoradi commented 5 years ago

@therkong I created a ticket. Can you please look into it? Thanks! Also, I was able to create the JSON based on the approach you mentioned. However, I do not fully understand the output as it is too verbose. Is it possible to generate a more readable one?