Network Programmabilty and Automation

Author Archives: Network Programmabilty and Automation

Passed AWS Associate Exam

I took the exam on 8th May 2021 and was able to crack it .Now you can call me AWS certified Associate .

I started thinking of giving the AWS associate exam more than a year back when my company provided us the free license of cloud Guru. We started a group of individuals who were interested in learning and taking the AWS associate exam. Our plan was to go through the cloud guru videos twice in a week during office hrs ( Allocated 1 hrs for learning ) and discuss any doubts related to topics. It all went very well for few weeks and suddenly people started missing sessions due to different reasons such as office meeting and workload. The group which started with 30 people reduced to 10 now and unfortunately I too dropped due to timing clash and office workload.

Almost after 6 months, again I started going through cloud Guru Videos and this time I was able to complete it and at that time i can easily rate myself 6 out of 10.

I went through AWS FAQ’s , I must say that they are must if you are preparing to take AWS exam.

I didn’t stop, Continue reading

TCP Transport control Protocol -PART 1

There was a need of protocol which can sent the data over a medium that is lossy . In simple term lossy is medium where data can be lost or alter.If an error occurs, there are 2 ways it can be taken care:

  • Error correction code
  • Resent the data again until its properly received

Resent the data need to fulfill 2 condition to make it worth , first whether the receiver has received the packet and and second whether the packet it received was the same one the sender sent.

This method to sent signal by receiver to sender that pack is received is known as Acknowledgement (ACK). So the sender should send a packet , stop and wait until ACK arrives from receiver.Once Ack is received by sender, it sent another packet and wait for Ack and this process continues.

But this process of stop and wait gives us 2 problem to taken care

  • How long should the sender wait for an ACK?
  • How to recognize duplicate Packets

Lets take each problem one by one starting with second one i.e recognize duplicate packets .

  • Question is how do i Recognize duplicate packet

Python String-Mutable Data Type

We all know that there are two types of Data types in Python ,i.e Mutable and other is immutable. In simple words, Mutable object can be change after its created whereas immutable object can’t

String,tuple,int,float,bool is example of immutable whereas list,dict and set are example of mutable data type.

Lets take an example of string data type :

We have string S=’Sujil’ and we need to change char ‘j’ to ‘n’ to make S=’Sunil’

>>> S ='Sunil'
>>> S ='Sujil'
>>> S=[2] = 'n'
  File "<input>", line 1
SyntaxError: can't assign to literal

We will get the SyntaxError , means we cannot change the defined string as string is Mutable data type .

Is there any way to change the Mutable data type string S=’Sujil’ to S=’Sunil’.

Yes , we can so the same . There is 3 way to do as below , choose the best way for urself.

Way 1:

>>> S ='Sujil'
>>> S
'Sujil'
>>> S = S[:2]+'n' +S[3:]
>>> S
'Sunil'
>>> type(S)
<class 'str'>

Way 2:

>>> S = 'Sujil'
>>> S
'Sujil'
>>> type(S)
<class 'str'>
>>> S =S.replace('j','n')
>>> S
'Sunil'

Way 3:

>>> S = 'Sujil'
>>> type(S)
<class 'str'>
>>>  Continue reading

JSON

JSON(Java Script Object Notification) is another data type apart from XML and YAML ,It’s easy for human and machine to understand than XML.

As usual, lets start with json example:

anurudh@anurudh:~/newfolder$ cat ex1_js.json
{
  "hostname": "Router1",
  "vendor": "cisco",
  "users": {
      "admin": 15,
      "storage": 10
},
  "vlans": [
     { 
       "vlan_name": "VLAN10",
       "vlan_id": 10
     },
     {
      "vlan_name": "VLAN20",
      "vlan_id": 20
     }
   ]
}

We like to put few point :

  • The whole thing is wrapped in curly braces {}.
  • JSON  use string values when describing the keys in these constructs.

Working with JSON in Python

anurudh@anurudh:~/newfolder$ cat ex1_js.py 
# Module need to be imported to use json 
import json

# File is open and stored in varible dat 
with open("ex1_js.json") as f:
     data = f.read()

# json.loads places json data into json_out (dictionary)
json_out = json.loads(data)

# print output
print(json_out)

# Lets check the data type 'json_out'
print("The Json document loaded as type {0}\n".format(type(json_out)))

# Method json.dumps will  convert python object back json string
json_out1 = json.dumps(json_out)

#print output
print(json_out1)

# Lets check the data type 'json_out1'
print("The Json document loaded as type {0}\n".format(type(json_out1)))

anurudh@anurudh:~/newfolder$ 

OUTPUT

anurudh@anurudh:~/newfolder$ python3 ex1_js.py 
{'hostname': 'Router1',  Continue reading