Python Functions – Basic

11 Dec 2016 Leave a comment

Python Function is a block of statements that can be used multiple times in a program. Its tedious task to use same block of statements multiple times, instead we can have function which contains same block of statement and can be called wherever there is need for the same.

A function in Python is defined by a def statement. The general syntax looks like this:

Def functionname( parameter list):



Optional parameters

Function can be called by using the following arguments

1 Default Parameters

A default argument is an argument that takes a default value if value is not provided in function.



Output :



2 Variable-length arguments

This is used in case where we need to process a function for more arguments than specified while defining the function.

These are variable-length arguments and are not named in function definition.



Output :



3 Anonymous

These functions are anonymous because they are not declared in the standard manner by def keyword

Lambda keyword is used to define small anonymous functions




Output :



  1. Return function

Statement return exits a function , optionally passing back an expression to call.

Program :





Local and Global Variable

Variables that are defined inside a function has local scope whereas defined outside function has global scope

















ARP – Address Resolution Protocol

9 Dec 2016 Leave a comment

When ever Network Engineer thinks  of ARP , first thing which comes in his mind is MAC address and layer 2.

MAC  Address is unique identity provided to NIC card for communication at layer 2. It’s also sometime referred as Burned-in-address or hardware Address.

Every network engineer should have good understanding of ARP. ARP is used to map  IP address to MAC-address used by data link protocol.

How ARP works , we will take a simple scenario to explain the concept of ARP



PC1 (IP wants to communicate with PC2 (

Lets first have a look at ARP header to have clear understanding of ARP fields.


Hardware type is of 2 byte which is network protocol type: in this case , it’s Ethernet which is 1.

Protocol type field is the internetwork protocol for which the ARP request is intended. In this case it’s IP, this has the value 0x0800.

Hardware Address length indicates length of hardware address, in this case Its Ethernet so hardware size is 6 bytes.

Protocol Address length indicates length of protocol address, In this case, its IP so protocol address length is 4 bytes.

Opcode is operation code that the sender is performing: 1 for request, 2 for reply, 3 and 4 in case of RARP(reverse ARP)

Sender protocol and Target protocol address is source and destination IP address.

Source hardware and Target hardware address is source Mac-Address and Destination Mac- address.

Initially, there is no ARP entry present on either of the PC, means that neither of the PC  or R1 is having any information of destination MAC address which is necessary for each other communication.

ARP entry of PC1 ,PC2 and R1 at initial phase








Now lets  initiate a ping request to PC2 from PC1 , as PC1  does not know the MAC address of router so , so first frame is broadcast asking  Who has ? Tell (PC1) . If you sees the first ping packet , its generally dropped ,it’s because of same reason.


Let’s have a look at detailed ARP capture

PC1 – Broadcast Frame


In this capture , we can see that ARP packet with Opcode =1(request) , with sender MAC, target MAC and Sender IP address, but as PC 1 is not aware of Target MAC address, so it puts broadcast address (ff:ff:ff:ff:ff:ff) for Target Mac address and broadcast the frame.

First frame is broadcast asking  Who has ? Tell

Router R1 configured with the IP address sends a reply which is unicast to source PC1 . Let’s have a look of the ARP capture for unicast frame

PC1 – Unicast Frame


Above ARP frame  capture is having Opcode as 2  i.e reply. The sender IP is now (R1 ) and destination IP is (PC1) ,accordingly R1 unicast the frame with source MAC  of itself and destination MAC of PC1.

R1 also saves the source MAC address in its ARP cache.

Thus overall process makes PC1 aware of the destination MAC of gateway IP (R1)


Similarly same processs is done at PC2 end to get the IP address resolve to MaC address. ARP  request is broadcast from PC2 for destination Mac address of and unicast packet with required details is received from R1 .

Below is Wireshark capture for PC2 for ARP frame (for broadcast and unicast ) for reference.

PC2 – Broadcast Frame


PC2- Unicast Frame


Thus  PC1 and PC2 are now  aware of the respective gateway hardware address. R1 now being too aware of PC1 and PC2 MAC address thus makes communication possible between PC1 and PC2


ARP entry of PC1 ,PC2 and R1 after successful ping.





Hope this post have cleared your any doubts regarding ARP   🙂 .comments are Welcome !!!


Be updated about the Telecom news and new Technology .

Like :

Python Loops – Basics

7 Dec 2016 Leave a comment


The if, while and for statements implement traditional control flow and provide the output depending upon the condition.




An if statement consists of a  condition followed by one or more statements.An if statement can be followed by an optional else statement.

Else statments is used with for loop to give the result when loop has exhausted  iterating the list.

If else stament is used with a while loop,the else  statment is executed when the condition becomes false.







While Loop

It’s an indefinite loop which keep iterating until some condition is met. There is no                guarantee regarding how many times the loop will go round .

While <condition >








Good use of indefinite loop is to have interactive loop. This loop help us to go through file data.We will have program using all the above mentioned terms in future posts


For Loop

Its iterate over the items of any sequence as a list or string.







Use of range with for loop 







Get Trained on the AWS Cloud

2 Dec 2016 Leave a comment

Get Trained on the AWS Cloud

AWSome Day Online Conference is a free, online training event that will provide a step-by-step introduction to the core AWS services for compute, storage, database and networking. AWS technical experts will explain key features and use cases, share best practices, walk through technical demos, and be available to answer your questions one-on-one.

Based on the AWS Essentials Course, AWSome Day is ideal for IT managers, business leaders, system engineers, system administrators, developers and architects who are eager to learn more about cloud computing and how to get started on the AWS Cloud.

Why you should attend:


  • Gain a deeper understanding of AWS core and application services
  • Learn how to deploy and automate your infrastructure on the AWS Cloud
  • Get your questions answered by our AWS experts
  • Receive a Certificate of Attendance when you complete the all modules

Register on below mentioned link:


Date: 6 December 2016
Time: 10am – 1.30pm IST
Location: Online

Categories: Cloud, Uncategorized Tags: , , ,

Python Basics – Part 2 cont…

30 Nov 2016 Leave a comment


A tuple is similar to a list. The difference between the two is that we cannot change the elements of a tuple once it is assigned whereas in a list, elements can be changed. A tuple is created by placing all the items (elements) inside a parentheses ()

  • We generally use tuple for different datatypes and list for homogeneous similar datatypes.
  • Since tuple are immutable, means value can not be changed.
  • Tuples that contain immutable elements can be used as key for a dictionary. With list, this is not possible.
  • If you have data that doesn’t change, implementing it as tuple will guarantee that it remains write-protected.

Empty tuples are constructed by an empty pair of parentheses; a tuple with one item is constructed by following a value with a comma (it is not sufficient to enclose a single value in parentheses)







5 .Dictionary

Python dictionary is an unordered set of key:value pairs , with the requirement that the keys are unique (within one dictionary). A pair of braces creates an empty dictionary: {}.Dictionary have no concept of order among elements.

Keys are unique within a dictionary while values may not be.The values of dictionary can be any type ,but the keys must be of an immutable such as strings,numbers or tuples.






Python Basics – Part 1

27 Nov 2016 Leave a comment

Let’s start with Python basics, with the help of program .Theory part in posts is just enough to understand the program.

Python Data Type:

  • Numbers
  • Strings
  • List
  • Tuple
  • Dictionary
  1. Numbers :  
    1.  Int                  1 ,10,-145, 22
    2. Float               1.1,0.9,-29.9
    3. Complex        1.4j, 4e+6j
  1. Strings

Way to remember how slices work in string  is to think of the indices as pointing between characters, with the left edge of the first character numbered 0. Then the right edge of the last character of a string of n characters has index n, for example:

“Crazyouters ”  represented in indices form

0 1 2 3 4 5 6 7 8 9 10 11
C r a z y r o u t e r s
-11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0

Program Code :





There are special operators in strings

Program Code :





3. List

The list is a most versatile datatype available in Python which can be written as a list of comma-separated values (items) between square brackets. Important thing about a list is that items in a list need not be of the same type. Unlike string  ,List is mutable type means its content can be changed.

Program Code :


output :





Categories: Uncategorized

Python – Must for Network Engineer

27 Nov 2016 Leave a comment

Automation is need of Time.We as network engineers have to go with automation to simplify major chunk of the work done by us.We can not escape from automation.I will be having series of Python posts starting from basics.I  will try to put all  learning  in post in most easiest way.

Let’s start with Basics.What is Python ? As per Wiki ,Python is a widely used high-level, general-purpose, interpreted, dynamic programming language.

In layman terms , it’s one of the coding  language much simpler, easy to understand and most importantly reduces number of code lines in C++ to fewer lines.

It was created by Guido van Rossum during 1985-1990.


Note:We will be doing coding in Python 3.

Windows:  can be installed from Site :

Linux: run below mentioned  command

$ sudo apt-get install python 3.5


Categories: Python, Uncategorized
%d bloggers like this: