Wednesday, February 1, 2017

Yesterday we started comparing virtual private network capabilities in public clouds. Azure started offering virtual networks from 2013 while AWS has been an early starter.  Azure's Virtual Network VN resembles AWS VPC in many aspects but we will also enumerate differences. That said Azure has kicked it up a notch.

We compared subnets which is a critical component for dividing networks. Both AWS and Azure allows any size network to be created as either single public subnet or a mix of public and private subnets. The difference is in the use of wizards which makes it super easy.
As with all networks, security is important to the network which can be configured at the instance, subnet and the overall network level.  Moreover, we can selectively permit or deny traffic using network ACLs
The use of network ACLs is complimentary to the use of security groups which helps cotnrol access Traffic can also be managed at any level using custom routing tables. By default, the routing table of the network is used unless a custom is specified. 
Additional  ip addresses can be assigned to the same instance in a network. However in order to do this, the instance has to be large enough and support multiple NIC cards. Both providers allow multiple NIC cards upto 8 only on specific large instances. 

#codingexercise
Given an integer array of n integers, find sum of bit differences in all pairs that can be formed from array elements. We gave an alternate way that involved enumerating all combinations of pairs from the array using the Combine method discussed earlier
int GetSumBitDifferencesUsingCombinations(List<int> A)
{
int ret = 0;
var pairs = new List<Tuple<int,int>>();
var seq = new List<int>();
int start = 0;
int level = 0;
Combine(pairs, ref seq, ref pairs, start, level);
pairs.ForEach ( x => ret += GetDiff(x.first, x.second));
return ret;
}
Void Combine (List<int> a, ref List<int> b, ref List<Tuple<int, int>> pairs, int start, int level)
{
For (int I = start ; I < a.Length; i++)
{
if (b.contains(a[i]) == false){
b[level] = a[i];
if (b.length == 2) {
var t = new Tuple<int, int>(){b[0], b[1]};
pairs.Add(t);
}
If (I < a.Length-1)
Combine(a,b,start+1,level+1)
B[level] = 0;
}
}
int GetDiff(uint a, uint b)
{
int ret = 0;
for (int i = 0; i < 32; i++)
{
uint c = 1 << i;
if (a & c != b & c)
         ret++;
}

return ret;
}

No comments:

Post a Comment