def pageRequest(url,source_ip,destination_ip,client_seq,client_ack,server_seq,server_ack):
	host,path=netUtils.serverNameExtract(sys.argv[1])
	data_req=layer5.reqGenGet(host,path)
	print(data_req)
	tcp_header = layer4.packTCPHeader(source_ip,destination_ip, source_port, client_seq, client_ack,'PSHACK',data_req)
	ip_header = layer3.packHeader(source_ip,destination_ip)
	
	pck = ip_header + tcp_header + data_req
	soc = socks.createSendSock()
	recsock=socks.createRecvSock()	
	soc.sendto(pck,(destination_ip,80))
	raw=socks.recv(recsock)
	ihl,tcph,src_ip,dest_ip,iph,data,payLength = netUtils.xtractPacket(raw)
	soc.close()
	recsock.close
	#socks.debugPrintSeqNo(client_seq,client_ack,server_seq,server_ack)
	[server_seq2,server_ack2]=layer4.getServerSeqNo(tcph)
	k=len(data_req)+client_seq
	#print("k="+str(k)) 
	#socks.debugPrintSeqNo(client_seq,client_ack,server_seq2,server_ack2)
	if tcph[5]==0x010 and tcph[1]==source_port and server_ack2==k and server_seq2==server_seq:
		print("ACK packet recieved for get. handshake done")	
		#body=downloadPage(tcph,iph,source_ip,destination_ip,client_seq,client_ack)
		data=socks.recData(destination_ip,source_ip,source_port,client_seq,client_ack,server_seq2,server_ack2)
		header_data,body=layer5.xtractHeaders(data)
	#print(header_data)
	else:
		sys.exit("NO ack recieved for GET.pLease try later")
	return body
def recPacket(destn_ip):
	
	recsock=socks.createRecvSock()
	while True:
		raw = socks.recv(recsock)
		
		ihl,tcph,source_ip,dest_ip,iph,data,payL = netUtils.xtractPacket(raw) 
		#server_ack=tcph[3]
		
		if source_ip == destn_ip and tcph[0]==80 and tcph[5]==18:
			#print "SYNACK recieved"
			#print tcph
			break
		
			
	
	return tcph
def getImpData(raw1):
	ihl,tcph,src_ip,dest_ip,iph,data,payLength = netUtils.xtractPacket(raw1)
	[server_seq,server_ack]=layer4.getServerSeqNo(tcph)
	[src_port,dest_port]=layer4.getPorts(tcph)
	flag=layer4.getPacType(tcph)
	return [src_ip,server_seq,server_ack,dest_port,payLength,flag,data]